public final class XML extends Object
XMLStreamReader and
XMLStreamWriter objects.
Creating a new XML stream reader:
try (AutoCloseableXMLStreamReader xml = XML.reader(in)) {
// Move XML stream to first element.
xml.next();
return reader.read(xml);
}
try (AutoCloseableXMLStreamWriter xml = XML.writer(out)) {
writer.write(value, xml);
}
final String indent = " ";
try (AutoCloseableXMLStreamWriter xml = XML.writer(out, indent)) {
writer.write(value, xml);
}| Modifier and Type | Method and Description |
|---|---|
static AutoCloseableXMLStreamReader |
reader(InputStream input)
Create a new XML stream reader from the given
input stream. |
static AutoCloseableXMLStreamWriter |
writer(OutputStream output)
Create a new
XMLStreamWriter from the given output stream. |
static AutoCloseableXMLStreamWriter |
writer(OutputStream output,
String indent)
Create a new
XMLStreamWriter from the given output stream. |
public static AutoCloseableXMLStreamReader reader(InputStream input) throws XMLStreamException
input stream.
The caller is responsible for closing the returned XMLStreamReader.
try (AutoCloseableXMLStreamReader xml = XML.reader(in)) {
// Move XML stream to first element.
xml.next();
return reader.read(xml);
}input - the input streamCloseable XML stream readerXMLStreamException - if the creation of the XML stream reader failsNullPointerException - if the given input stream is
nullpublic static AutoCloseableXMLStreamWriter writer(OutputStream output, String indent) throws XMLStreamException
XMLStreamWriter from the given output stream.
The caller is responsible for closing the returned XMLStreamWriter.
try (AutoCloseableXMLStreamWriter xml = XML.writer(out, " ")) {
writer.write(value, xml);
}output - the underlying output streamindent - the element indent used for the XML outputXMLStreamWriter instanceXMLStreamException - if an error occurs while creating the XML
stream writerNullPointerException - if the given output stream is
nullpublic static AutoCloseableXMLStreamWriter writer(OutputStream output) throws XMLStreamException
XMLStreamWriter from the given output stream.
The caller is responsible for closing the returned XMLStreamWriter.
try (AutoCloseableXMLStreamWriter xml = XML.writer(out)) {
writer.write(value, xml);
}output - the underlying output streamXMLStreamWriter instanceXMLStreamException - if an error occurs while creating the XML
stream writerNullPointerException - if the given output stream is
null© 2007-2019 Franz Wilhelmstötter (2019-11-18 20:30)