Here you can find the source of parse(File file)
public static Document parse(File file) throws SAXException, IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2014 Gabriel Skantze./*ww w. j a v a 2 s . com*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html * * Contributors: * Gabriel Skantze - initial API and implementation ******************************************************************************/ import java.io.File; import java.io.IOException; 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 parse(File file) throws SAXException, IOException { return getBuilder().parse(file); } public static DocumentBuilder getBuilder() { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); try { return dbf.newDocumentBuilder(); } catch (ParserConfigurationException e) { e.printStackTrace(); } return null; } }