public static Document newDocument(InputStream xmlStream, boolean namespaceAware) throws SAXException, IOException, ParserConfigurationException {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(namespaceAware);
        DocumentBuilder builder = factory.newDocumentBuilder();
        return builder.parse(xmlStream);
    }
public static Document newDocument ( InputStream xmlStream , boolean namespaceAware ) throws SAXException , IOException , ParserConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; factory . setNamespaceAware ( namespaceAware ) ; DocumentBuilder builder = factory . newDocumentBuilder ( ) ; return builder . parse ( xmlStream ) ; }
Create a {@link Document} from an {@link InputStream}.

@param xmlStream      the XML input, the document is created from
@param namespaceAware if namespaces are used in the created document
@return created document
@throws SAXException                 if XML contains an error
@throws IOException                  if XML is not readable
@throws ParserConfigurationException if the parser is not properly configured