Here you can find the source of parse(File file)
public static Document parse(File file) throws SAXException, IOException, ParserConfigurationException
//package com.java2s; //License from project: Open Source License 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.InputSource; import org.xml.sax.SAXException; public class Main { public static Document parse(File file) throws SAXException, IOException, ParserConfigurationException { return getDocumentBuilder().parse(file); }/* w ww. j a v a2 s . c o m*/ public static Document parse(InputSource source) throws ParserConfigurationException, SAXException, IOException { return getDocumentBuilder().parse(source); } public static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); dbFactory.setNamespaceAware(true); return dbFactory.newDocumentBuilder(); } }