Java Utililty Methods XML Document from Stream

List of utility methods to do XML Document from Stream

Description

The list of methods to do XML Document from Stream are organized into topic(s).

Method

DocumentloadXmlDocumentFromStream(@Nonnull InputStream in)
Load the given InputStream as an XML document.
Preconditions.checkNotNull(in, "Inputstream can not be null");
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
return documentBuilder.parse(in);
DocumentloadXMLFrom(final InputStream is)
Loads an XML document from the input stream into a DOM Document.
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = null;
builder = factory.newDocumentBuilder();
assert builder != null;
final Document doc = builder.parse(is);
is.close();
return doc;
...
DocumentloadXmlFromInputSource(InputSource is)
load Xml From Input Source
try {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    return db.parse(is);
} catch (ParserConfigurationException e) {
    throw new RuntimeException(e);
} catch (SAXException e) {
    throw new RuntimeException(e);
...
DocumentreadXML(InputStream input)
Parses the given input stream and returns the corresponding desirialized XML document.
return readXML(new InputStreamReader(input, "UTF-8"));
DocumentreadXml(InputStream inputStream)
read Xml
try {
    Document document = newDocumentBuilder().parse(inputStream);
    document.setXmlStandalone(true);
    return document;
} catch (IOException e) {
    throw new IllegalArgumentException(e);
} catch (SAXException e) {
    throw new IllegalArgumentException(e);
...
DocumentreadXML(InputStream inputStream, EntityResolver resolver, ErrorHandler error)
read XML
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db;
try {
    db = dbf.newDocumentBuilder();
    if (resolver != null) {
        db.setEntityResolver(resolver);
    if (error != null) {
...
NodereadXML(InputStream inStream)
Reads the argument XML input stream.
try {
    DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = builderFactory.newDocumentBuilder();
    Document doc = builder.parse(inStream);
    inStream.close();
    return doc.getDocumentElement();
} catch (SAXException saxEx) {
    throw new IllegalArgumentException(null, saxEx);
...
DocumentreadXML(InputStream is)
Read input stream into XML Document element
javax.xml.parsers.DocumentBuilderFactory dbf = javax.xml.parsers.DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder();
org.w3c.dom.Document doc = db.parse(is);
return doc;