Examples of XMLInputFactory


Examples of javax.xml.stream.XMLInputFactory

        assertNotNull(obj);

        java.math.BigDecimal fixedValue = new java.math.BigDecimal("12345.67");
        obj.setValue(fixedValue);
       
        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
        outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
     
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        XMLEventWriter evtWriter = null;
        try {
            evtWriter = outputFactory.createXMLEventWriter(outStream);
        } catch (XMLStreamException ex) {
        }
        assertNotNull(evtWriter);
       
        try {
            XMLEventFactory factory = XMLEventFactory.newInstance();
            staxObject.writeObjectToStax(obj, evtWriter, factory);
            evtWriter.flush();
        } catch (XMLStreamException ex) {
           
        }

        ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());       
        XMLEventReader evtReader = null;
        try {           
            evtReader = inputFactory.createXMLEventReader(inStream);
            // read the first tag which should be a start document
            XMLEvent evt = evtReader.nextEvent();
            assertTrue(evt.isStartDocument());
        } catch (XMLStreamException ex) {
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.