@Override public void start(File file) { // xml output XMLOutputFactory2 xmlOutput = (XMLOutputFactory2) XMLOutputFactory2 .newInstance(); xmlOutput.configureForSpeed(); xmlOutput.setProperty(XMLOutputFactory2.IS_REPAIRING_NAMESPACES, false); try { // output file writer OutputStream outStream = new FileOutputStream(file); if (outStream != null) { XMLStreamWriter2 xmlWriteStream = (XMLStreamWriter2) xmlOutput .createXMLStreamWriter(outStream, "ISO-8859-1"); writeDocument(viewer.getGraphLayout().getGraph(), xmlWriteStream); xmlWriteStream.flush(); xmlWriteStream.close(); outStream.flush(); outStream.close(); } } catch (Exception e) { ErrorDialog.show(e); } }
XMLOutputFactory2 xmlOutput = (XMLOutputFactory2) XMLOutputFactory2.newInstance(); xmlOutput.configureForXmlConformance(); xmlOutput.setProperty(XMLOutputFactory2.IS_REPAIRING_NAMESPACES, false); try { XMLStreamWriter2 xmlw = (XMLStreamWriter2) xmlOutput.createXMLStreamWriter(new FileWriter(file), CharsetNames.CS_UTF8);
/** * Method for constructing Stax stream writer to write xml content * to specified file. * Underlying stream writer will be constructed using Stax factory * this StaxMate factory was constructed with. *<p> * Encoding used will be UTF-8. */ public XMLStreamWriter2 createStax2Writer(File f) throws XMLStreamException { if (_stax2Factory != null) { /* have real stax2 factory; can create more optimal writer * (most importantly: one that automatically closes the writer) */ Stax2FileResult res = new Stax2FileResult(f); return (XMLStreamWriter2) _stax2Factory.createXMLStreamWriter(res); } /* No, just stax1 factory. Could use StreamResult; but some * impls might not recognize it... immediate problem here: * auto-closing won't work. */ try { FileOutputStream out = new FileOutputStream(f); return Stax2WriterAdapter.wrapIfNecessary(_staxFactory.createXMLStreamWriter(out)); } catch (FileNotFoundException fex) { throw new XMLStreamException(fex); } }
try XMLOutputFactory2 output = (XMLOutputFactory2) XMLOutputFactory2.newFactory(); writer = (XMLStreamWriter2) output.createXMLStreamWriter(outputStream);
/** * Constructs a new {@code XmiStreamWriter} on the given {@code stream}. * * @param stream the output stream to write * * @throws IOException if an I/O error occurs when writing */ public XmiStreamWriter(OutputStream stream) throws IOException { super(stream); XMLOutputFactory factory = XMLOutputFactory2.newInstance(); configure(factory); try { writer = factory.createXMLStreamWriter(new BufferedOutputStream(stream), XmiConstants.ENCODING); } catch (XMLStreamException e) { throw new IOException(e); } }
/** * Method for constructing Stax stream writer to write xml content * to specified file. * Underlying stream writer will be constructed using Stax factory * this StaxMate factory was constructed with. *<p> * Encoding used will be UTF-8. */ public XMLStreamWriter2 createStax2Writer(File f) throws XMLStreamException { if (_stax2Factory != null) { /* have real stax2 factory; can create more optimal writer * (most importantly: one that automatically closes the writer) */ Stax2FileResult res = new Stax2FileResult(f); return (XMLStreamWriter2) _stax2Factory.createXMLStreamWriter(res); } /* No, just stax1 factory. Could use StreamResult; but some * impls might not recognize it... immediate problem here: * auto-closing won't work. */ try { FileOutputStream out = new FileOutputStream(f); return Stax2WriterAdapter.wrapIfNecessary(_staxFactory.createXMLStreamWriter(out)); } catch (FileNotFoundException fex) { throw new XMLStreamException(fex); } }
private void extract(String inputFile, String outputFile) throws IOException, XMLStreamException { System.out.println("Parsing pages and extracting links..."); long startTime = System.currentTimeMillis(); XMLOutputFactory outputFactory = XMLOutputFactory2.newInstance(); XMLStreamWriter writer = outputFactory.createXMLStreamWriter(new FileOutputStream(outputFile), "UTF-8"); writer.writeStartDocument(); writer.writeStartElement("d"); LinkExtractor linkExtractor = new LinkExtractor(writer); linkExtractor.parse(inputFile); writer.writeEndElement(); writer.writeEndDocument(); writer.close(); long elapsedSeconds = (System.currentTimeMillis() - startTime) / 1000; System.out.printf("\n%d pages parsed in %d seconds.\n", linkExtractor.getPageCount(), elapsedSeconds); }
public void start() throws JAXBException { XMLOutputFactory2 xmlOutput = (XMLOutputFactory2) XMLOutputFactory2.newInstance(); xmlOutput.configureForSpeed(); xmlOutput.setProperty(XMLOutputFactory2.IS_REPAIRING_NAMESPACES, false); XMLStreamWriter2 xmlWriteStream = (XMLStreamWriter2) xmlOutput.createXMLStreamWriter(outStream, CharsetNames.CS_UTF8); buildDocument(xmlWriteStream, graph);
public Observable<JsonNode> generate(final Observable<JsonNode> recordGDM, final OutputStream outputStream) throws XMLStreamException { LOG.debug("start generating Solr Update XML out of GDM"); final XMLStreamWriter writer = xmlOutputFactory.createXMLStreamWriter(outputStream); writer.writeStartDocument(StandardCharsets.UTF_8.toString(), XML_VERSION); // process records to XML final SolrUpdateXMLRelationshipHandler relationshipHandler = new CBDRelationshipHandler(writer); final CBDNodeHandler connectRelsAndNodeHandler = new CBDNodeHandler(relationshipHandler); final SolrUpdateXMLNodeHandler startNodeHandler = new CBDStartNodeHandler(connectRelsAndNodeHandler, writer); final XMLExportOperator operator = new XMLExportOperator(writer, startNodeHandler); return recordGDM.lift(operator); }
/** * Default constructor * @param output which file to write to */ public XmlWikipediaPageWriter(File output) { try { this.writer = (XMLStreamWriter2)XMLOutputFactory2.newInstance().createXMLStreamWriter(new BufferedOutputStream(new FileOutputStream(output)), "utf-8"); this.output = output; this.writer.writeStartDocument("utf-8", "1.0"); this.writer.writeSpace("\n"); this.writer.writeStartElement("pages"); this.writer.writeSpace("\n"); } catch (XMLStreamException e) { throw new IOError(e); } catch (FileNotFoundException e) { throw new IOError(e); } }
XMLOutputFactory2 xmlOutput = (XMLOutputFactory2) XMLOutputFactory2.newInstance(); xmlOutput.configureForSpeed(); xmlOutput.setProperty(XMLOutputFactory2.IS_REPAIRING_NAMESPACES, false); try { XMLStreamWriter2 xmlWriteStream = (XMLStreamWriter2) xmlOutput.createXMLStreamWriter(outStream, CharsetNames.CS_UTF8);
public Observable<JsonNode> generate(final Observable<JsonNode> recordGDM, final OutputStream outputStream) throws XMLStreamException { LOG.debug("start generating XML out of GDM"); final XMLStreamWriter writer = xmlOutputFactory.createXMLStreamWriter(outputStream); writer.writeStartDocument(StandardCharsets.UTF_8.toString(), XML_VERSION); // process records to XML final XMLRelationshipHandler relationshipHandler; if (originalDataTypeIsXML) { relationshipHandler = new CBDRelationshipXMLDataModelHandler(writer); } else { relationshipHandler = new CBDRelationshipHandler(writer); } final CBDNodeHandler connectRelsAndNodeHandler = new CBDNodeHandler(relationshipHandler); final XMLNodeHandler startNodeHandler = new CBDStartNodeHandler(connectRelsAndNodeHandler, writer); final XMLExportOperator operator = new XMLExportOperator(writer, startNodeHandler); return recordGDM.lift(operator); }
XMLOutputFactory2 xmlOutput = (XMLOutputFactory2) XMLOutputFactory2.newInstance(); xmlOutput.configureForSpeed(); xmlOutput.setProperty(XMLOutputFactory2.IS_REPAIRING_NAMESPACES, false); try { XMLStreamWriter2 xmlWriteStream = (XMLStreamWriter2) xmlOutput.createXMLStreamWriter(outStream, CharsetNames.CS_UTF8);
final XMLStreamWriter writer = xmlOutputFactory.createXMLStreamWriter(outputStream);
XMLOutputFactory2 xmlOutput = (XMLOutputFactory2) XMLOutputFactory2.newInstance(); xmlOutput.configureForSpeed(); xmlOutput.setProperty(XMLOutputFactory2.IS_REPAIRING_NAMESPACES, false); try { XMLStreamWriter2 xmlWriteStream = (XMLStreamWriter2) xmlOutput.createXMLStreamWriter(outStream, CharsetNames.CS_UTF8);
reader = (XMLStreamReader2) inputFactory.createXMLStreamReader(new CharArrayReader(chars, offset, length)); writer = (XMLStreamWriter2) outputFactory.createXMLStreamWriter(new StringBuilderWriter(output));
writer = (XMLStreamWriter2) outputFactory.createXMLStreamWriter(stringBuilderWriter);
XMLStreamWriter2 writer = (XMLStreamWriter2) output.createXMLStreamWriter(os);