org.codehaus.stax2.XMLOutputFactory2.createXMLStreamWriter()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中org.codehaus.stax2.XMLOutputFactory2.createXMLStreamWriter()方法的一些代码示例,展示了XMLOutputFactory2.createXMLStreamWriter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLOutputFactory2.createXMLStreamWriter()方法的具体详情如下:
包路径:org.codehaus.stax2.XMLOutputFactory2
类名称:XMLOutputFactory2
方法名:createXMLStreamWriter

XMLOutputFactory2.createXMLStreamWriter介绍

暂无

代码示例

代码示例来源:origin: org.codehaus.staxmate/staxmate

/**
 * 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);
  }
}

代码示例来源:origin: FasterXML/StaxMate

/**
 * 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);
  }
}

代码示例来源:origin: dswarm/dswarm

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);
}

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

XMLStreamWriter2 xmlWriteStream = (XMLStreamWriter2) xmlOutput.createXMLStreamWriter(outStream, CharsetNames.CS_UTF8);
buildDocument(xmlWriteStream, graph);

代码示例来源:origin: dswarm/dswarm

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);
}

代码示例来源:origin: com.github.skjolber.xml-log-filter/xml-log-filter-stax

reader = (XMLStreamReader2) inputFactory.createXMLStreamReader(new CharArrayReader(chars, offset, length));
writer = (XMLStreamWriter2) outputFactory.createXMLStreamWriter(new StringBuilderWriter(output));

代码示例来源:origin: dswarm/dswarm

final XMLStreamWriter writer = xmlOutputFactory.createXMLStreamWriter(outputStream);

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

try {
  XMLStreamWriter2 xmlw = (XMLStreamWriter2) xmlOutput.createXMLStreamWriter(new FileWriter(file), CharsetNames.CS_UTF8);

代码示例来源:origin: com.github.skjolber.xml-log-filter/xml-log-filter-stax

writer = (XMLStreamWriter2) outputFactory.createXMLStreamWriter(stringBuilderWriter);

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2-default

@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);
  }
}

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

try {
  XMLStreamWriter2 xmlWriteStream = (XMLStreamWriter2) xmlOutput.createXMLStreamWriter(outStream, CharsetNames.CS_UTF8);

代码示例来源:origin: girtel/Net2Plan

XMLStreamWriter2 writer = (XMLStreamWriter2) output.createXMLStreamWriter(os);

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

try {
  XMLStreamWriter2 xmlWriteStream = (XMLStreamWriter2) xmlOutput.createXMLStreamWriter(outStream, CharsetNames.CS_UTF8);

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

try {
  XMLStreamWriter2 xmlWriteStream = (XMLStreamWriter2) xmlOutput.createXMLStreamWriter(outStream, CharsetNames.CS_UTF8);

代码示例来源:origin: girtel/Net2Plan

writer = (XMLStreamWriter2) output.createXMLStreamWriter(outputStream);

相关文章