Here you can find the source of parse(File file)
public static Document parse(File file) throws SAXException, IOException, ParserConfigurationException, FactoryConfigurationError
//package com.java2s; /* /*from w ww . j a va2s . c o m*/ * This file is part of DISMOD Core. * ? Copyright 2003-2011 Fraunhofer Institut f. Materialfluss und Logistik. * http://www.iml.fraunhofer.de, http://www.verkehrslogistik.de * * DISMOD Core is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DISMOD Core is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with DISMOD Core. If not, see <http://www.gnu.org/licenses/>. */ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.xml.sax.SAXException; public class Main { public static Document parse(File file) throws SAXException, IOException, ParserConfigurationException, FactoryConfigurationError { FileInputStream in = new FileInputStream(file); Document out = parse(in); in.close(); return out; } public static Document parse(URL url) throws SAXException, IOException, ParserConfigurationException, FactoryConfigurationError { InputStream in = url.openStream(); Document out = parse(in); in.close(); return out; } public static Document parse(InputStream in) throws SAXException, IOException, ParserConfigurationException, FactoryConfigurationError { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(in); return document; } }