Here you can find the source of loadDocument(InputStream is)
public static Document loadDocument(InputStream is) throws SAXException, IOException, ParserConfigurationException
//package com.java2s; /******************************************************************************* * Copyright (c) 2010-2014, Zoltan Ujhelyi, Istvan Rath and Daniel Varro * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w w w .ja v a 2s. c om * Zoltan Ujhelyi - initial API and implementation *******************************************************************************/ import java.io.IOException; import java.io.InputStream; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.xml.sax.SAXException; public class Main { private static final DocumentBuilderFactory FACTORY = DocumentBuilderFactory.newInstance(); public static Document loadDocument(InputStream is) throws SAXException, IOException, ParserConfigurationException { return getDefaultFactory().newDocumentBuilder().parse(is); } public static DocumentBuilderFactory getDefaultFactory() { return FACTORY; } }