Here you can find the source of load(InputStream inputStream)
public static Document load(InputStream inputStream) throws Exception
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.InputStream; public class Main { public static Document load(InputStream inputStream) throws Exception { return getDocumentBuilder().parse(inputStream); }//from ww w. ja v a 2 s. c o m public static Document load(String uri) throws Exception { return getDocumentBuilder().parse(uri); } private static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException { DocumentBuilder documentBuilder; DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setValidating(false); // dtd isn't available; would be nice to attempt to validate documentBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); documentBuilderFactory.setNamespaceAware(true); documentBuilder = documentBuilderFactory.newDocumentBuilder(); return documentBuilder; } }