public void createInitXML(String xml_path,String subnet,String count) throws SAXException, ParserConfigurationException, IOException, XMLStreamException{
XMLOutputFactory xof = XMLOutputFactory.newInstance();
XMLStreamWriter xtw = null;
xtw = xof.createXMLStreamWriter(new FileWriter("init.xml"));
xtw.writeStartDocument("utf-8","1.0");
xtw.writeCharacters("\n");
xtw.writeStartElement("SETTINGS");
xtw.writeCharacters("\n");
xtw.writeStartElement("XML_PATH");
xtw.writeCharacters("\n");
xtw.writeCharacters(xml_path);
xtw.writeCharacters("\n");
xtw.writeEndElement();
xtw.writeCharacters("\n");
xtw.writeStartElement("SUBNET");
xtw.writeCharacters("\n");
xtw.writeCharacters(subnet);
xtw.writeCharacters("\n");
xtw.writeEndElement();
xtw.writeCharacters("\n");
xtw.writeStartElement("count");
xtw.writeCharacters("\n");
xtw.writeCharacters(count);
xtw.writeCharacters("\n");
xtw.writeEndElement();
xtw.writeCharacters("\n");
xtw.writeEndElement();
xtw.writeCharacters("\n");
xtw.writeEndDocument();
xtw.flush();
xtw.close();
}
java类javax.xml.stream.XMLOutputFactory的实例源码
XMLController.java 文件源码
项目:amelia
阅读 20
收藏 0
点赞 0
评论 0
DefaultFactoryWrapperTest.java 文件源码
项目:openjdk-jdk10
阅读 20
收藏 0
点赞 0
评论 0
@DataProvider(name = "jaxpFactories")
public Object[][] jaxpFactories() throws Exception {
return new Object[][] {
{ DocumentBuilderFactory.newInstance(), (Produce)factory -> ((DocumentBuilderFactory)factory).newDocumentBuilder() },
{ SAXParserFactory.newInstance(), (Produce)factory -> ((SAXParserFactory)factory).newSAXParser() },
{ SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI), (Produce)factory -> ((SchemaFactory)factory).newSchema() },
{ TransformerFactory.newInstance(), (Produce)factory -> ((TransformerFactory)factory).newTransformer() },
{ XMLEventFactory.newInstance(), (Produce)factory -> ((XMLEventFactory)factory).createStartDocument() },
{ XMLInputFactory.newInstance(), (Produce)factory -> ((XMLInputFactory)factory).createXMLEventReader(new StringReader("")) },
{ XMLOutputFactory.newInstance(), (Produce)factory -> ((XMLOutputFactory)factory).createXMLEventWriter(new StringWriter()) },
{ XPathFactory.newInstance(), (Produce)factory -> ((XPathFactory)factory).newXPath() },
{ DatatypeFactory.newInstance(), (Produce)factory -> ((DatatypeFactory)factory).newXMLGregorianCalendar() }
};
}
XmlResult.java 文件源码
项目:fluentxml4j
阅读 49
收藏 0
点赞 0
评论 0
public XMLStreamWriter getXMLStreamWriter(AutoFlushPolicy autoFlush)
{
try
{
return XMLStreamWriterProxy.proxyFor(XMLOutputFactory.newFactory().createXMLStreamWriter(getOutputStream()), autoFlush == AutoFlushPolicy.AUTO_FLUSH);
}
catch (XMLStreamException ex)
{
throw new IllegalStateException(ex);
}
}
TransformTest.java 文件源码
项目:openjdk-jdk10
阅读 17
收藏 0
点赞 0
评论 0
@BeforeClass
public void setup() throws Exception {
ifac = XMLInputFactory.newInstance();
ofac = XMLOutputFactory.newInstance();
tfac = TransformerFactory.newInstance();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
db = dbf.newDocumentBuilder();
xml = Files.readAllBytes(Paths.get(XML_DIR + "cities.xml"));
template = Files.readAllBytes(Paths.get(XML_DIR + "cities.xsl"));
xmlDoc = db.parse(xmlInputStream());
}
StaxUtils.java 文件源码
项目:fluentxml4j
阅读 31
收藏 0
点赞 0
评论 0
public static XMLStreamWriter newXMLStreamWriter(OutputStream out)
{
try
{
return XMLOutputFactory.newFactory().createXMLStreamWriter(out);
}
catch (XMLStreamException ex)
{
throw new IllegalStateException(ex);
}
}
StaxUtils.java 文件源码
项目:fluentxml4j
阅读 27
收藏 0
点赞 0
评论 0
public static XMLEventWriter newXMLEventWriter(OutputStream out)
{
try
{
return XMLOutputFactory.newFactory().createXMLEventWriter(out);
}
catch (XMLStreamException ex)
{
throw new IllegalStateException(ex);
}
}
XmlHashMapBodyWriter.java 文件源码
项目:Nasapi
阅读 18
收藏 0
点赞 0
评论 0
@Override
public void writeTo(HashMap hashMap, Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> multivaluedMap, OutputStream outputStream) throws IOException, WebApplicationException {
try {
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
XMLStreamWriter xmlWriter = outputFactory.createXMLStreamWriter(outputStream);
xmlWriter.writeStartElement("entity");
writeValue(hashMap, xmlWriter);
xmlWriter.writeEndElement();
xmlWriter.flush();
xmlWriter.close();
} catch (XMLStreamException e) {
throw new IOException(e);
}
}
XmlArrayLstBodyWriter.java 文件源码
项目:Nasapi
阅读 21
收藏 0
点赞 0
评论 0
@Override
public void writeTo(ArrayList arrayList, Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> multivaluedMap, OutputStream outputStream) throws IOException, WebApplicationException {
try {
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
XMLStreamWriter xmlWriter = outputFactory.createXMLStreamWriter(outputStream);
writeValue(arrayList, xmlWriter);
xmlWriter.flush();
xmlWriter.close();
} catch (XMLStreamException e) {
throw new IOException(e);
}
}
DocumentStaxUtils.java 文件源码
项目:gate-core
阅读 34
收藏 0
点赞 0
评论 0
/**
* Returns a string containing the specified document in GATE XML
* format.
*
* @param doc the document
*/
public static String toXml(Document doc) {
try {
if(outputFactory == null) {
outputFactory = XMLOutputFactory.newInstance();
}
StringWriter sw = new StringWriter(doc.getContent().size().intValue()
* DocumentXmlUtils.DOC_SIZE_MULTIPLICATION_FACTOR);
XMLStreamWriter xsw = outputFactory.createXMLStreamWriter(sw);
// start the document
if(doc instanceof TextualDocument) {
xsw.writeStartDocument(((TextualDocument)doc).getEncoding(), "1.0");
}
else {
xsw.writeStartDocument("1.0");
}
newLine(xsw);
writeDocument(doc, xsw, "");
xsw.close();
return sw.toString();
}
catch(XMLStreamException xse) {
throw new GateRuntimeException("Error converting document to XML", xse);
}
}
XMLStreamer.java 文件源码
项目:Equella
阅读 20
收藏 0
点赞 0
评论 0
public XMLStreamer(Writer writer)
{
this.output = writer;
try
{
xml = XMLOutputFactory.newInstance().createXMLStreamWriter(output);
}
catch( Exception ex )
{
throw new RuntimeException(ex);
}
}