Here you can find the source of getDocument(InputStream xml)
public static Document getDocument(InputStream xml) throws java.io.IOException, org.xml.sax.SAXException
//package com.java2s; //License from project: Open Source License import java.io.InputStream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; public class Main { public static Document getDocument(InputStream xml) throws java.io.IOException, org.xml.sax.SAXException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setIgnoringElementContentWhitespace(true); DocumentBuilder db;// w w w .j av a 2 s . c om try { db = dbf.newDocumentBuilder(); } catch (javax.xml.parsers.ParserConfigurationException e) { throw new RuntimeException("Parser misconfiguration"); } Document doc = db.parse(xml); return doc; } }