Here you can find the source of getDocument(File file)
public static org.w3c.dom.Document getDocument(File file) throws SAXException, IOException, ParserConfigurationException
//package com.java2s; 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.xml.sax.SAXException; public class Main { public static org.w3c.dom.Document getDocument(String xmlPath) throws SAXException, IOException, ParserConfigurationException { return getDocument(new File(xmlPath)); }/*w ww.ja va2 s . co m*/ public static org.w3c.dom.Document getDocument(File file) throws SAXException, IOException, ParserConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(file); } }