Package javax.xml.stream

Examples of javax.xml.stream.XMLOutputFactory


  public void extract() {
    XMLInputFactory xif = XMLInputFactory.newInstance();
    XMLStreamReader reader = null;
    InputStream is = null;
   
    XMLOutputFactory xof = XMLOutputFactory.newInstance();
    XMLStreamWriter writer = null;
    OutputStream os = null;
   
    try {
      log.info("Reading data from " + inputFile);
     
      is = new FileInputStream(inputFile);
      reader = xif.createXMLStreamReader(is);
     
      os = new FileOutputStream(trainingOutputFile);
      writer = xof.createXMLStreamWriter(os);
      int trainingDataCount = extractXMLData(reader, writer, trainingDataSize);
      os.close();
     
      os = new FileOutputStream(testOutputFile);
      writer = xof.createXMLStreamWriter(os);
      int testDataCount = extractXMLData(reader, writer, testDataSize);
      os.close();
     
      log.info("Extracted " + trainingDataCount + " rows of training data");
      log.info("Extracted " + testDataCount     + " rows of test data");
View Full Code Here


        }
    }

    private void writeInfoPlist(File file) throws IOException {
        Writer out = new BufferedWriter(new FileWriter(file));
        XMLOutputFactory output = XMLOutputFactory.newInstance();

        try {
            XMLStreamWriter xout = output.createXMLStreamWriter(out);

            // Write XML declaration
            xout.writeStartDocument();
            xout.writeCharacters("\n");
View Full Code Here

           
            StAXArtifactProcessor<Composite> processor = staxProcessors.getProcessor(Composite.class);
           
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            try {
                XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
                XMLStreamWriter writer = outputFactory.createXMLStreamWriter(bos);
                processor.write(composite, writer);
                writer.flush();
                writer.close();
            } catch (Exception ex) {
                System.out.println(ex.toString());
View Full Code Here

    private XMLInputFactory inputFactory;
    private XMLOutputFactory outputFactory;

    @Converter
    public XMLEventWriter createXMLEventWriter(OutputStream out, Exchange exchange) throws XMLStreamException {
        XMLOutputFactory factory = getOutputFactory();
        try {
            return factory.createXMLEventWriter(IOHelper.buffered(out), IOHelper.getCharsetName(exchange));
        } finally {
            returnXMLOutputFactory(factory);
        }
    }
View Full Code Here

        }
    }
   
    @Converter
    public XMLEventWriter createXMLEventWriter(Writer writer) throws XMLStreamException {
        XMLOutputFactory factory = getOutputFactory();
        try {
            return factory.createXMLEventWriter(IOHelper.buffered(writer));
        } finally {
            returnXMLOutputFactory(factory);
        }
    }
View Full Code Here

        }
    }

    @Converter
    public XMLEventWriter createXMLEventWriter(Result result) throws XMLStreamException {
        XMLOutputFactory factory = getOutputFactory();
        try {
            if (result instanceof DOMResult && !isWoodstox(factory)) {
                //FIXME - if not woodstox, this will likely not work well
                //likely should copy CXF's W3CDOM stuff
                LOG.info("DOMResult is known to have issues with {0}. We suggest using Woodstox",
                         factory.getClass());
            }
            return factory.createXMLEventWriter(result);
        } finally {
            returnXMLOutputFactory(factory);
        }
    }
View Full Code Here

        }
    }
   
    @Converter
    public XMLStreamWriter createXMLStreamWriter(OutputStream outputStream, Exchange exchange) throws XMLStreamException {
        XMLOutputFactory factory = getOutputFactory();
        try {
            return factory.createXMLStreamWriter(IOHelper.buffered(outputStream), IOHelper.getCharsetName(exchange));
        } finally {
            returnXMLOutputFactory(factory);
        }
    }
View Full Code Here

        }
    }

    @Converter
    public XMLStreamWriter createXMLStreamWriter(Writer writer) throws XMLStreamException {
        XMLOutputFactory factory = getOutputFactory();
        try {
            return factory.createXMLStreamWriter(IOHelper.buffered(writer));
        } finally {
            returnXMLOutputFactory(factory);
        }
    }
View Full Code Here

        }
    }

    @Converter
    public XMLStreamWriter createXMLStreamWriter(Result result) throws XMLStreamException {
        XMLOutputFactory factory = getOutputFactory();
        try {
            if (result instanceof DOMResult && !isWoodstox(factory)) {
                //FIXME - if not woodstox, this will likely not work well
                //likely should copy CXF's W3CDOM stuff
                LOG.info("DOMResult is known to have issues with {0}. We suggest using Woodstox",
                         factory.getClass());
            }
            return factory.createXMLStreamWriter(result);
        } finally {
            returnXMLOutputFactory(factory);
        }
    }
View Full Code Here

            INPUT_FACTORY_POOL.offer(factory);
        }
    }
   
    private XMLOutputFactory getXMLOutputFactory() {
        XMLOutputFactory f = OUTPUT_FACTORY_POOL.poll();
        if (f == null) {
            f = XMLOutputFactory.newInstance();
        }
        return f;
    }
View Full Code Here

TOP

Related Classes of javax.xml.stream.XMLOutputFactory

Copyright © 2018 www.massapicom. 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.