Here you can find the source of getDocument(InputStream is)
public static Document getDocument(InputStream is) throws ParserConfigurationException, SAXException, IOException
//package com.java2s; import java.io.IOException; import java.io.InputStream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.xml.sax.SAXException; public class Main { public static Document getDocument(InputStream is) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory domfactory = DocumentBuilderFactory .newInstance();//w w w.j av a 2 s.com domfactory.setNamespaceAware(true); // never forget this! DocumentBuilder builder = domfactory.newDocumentBuilder(); Document doc = builder.parse(is); return doc; } }