Here you can find the source of loadDocument(File file)
public static Document loadDocument(File file) throws ParserConfigurationException, SAXException, IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; 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 loadDocument(File file) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); Document doc;//w ww. j a v a 2 s .c o m DocumentBuilder db; db = dbf.newDocumentBuilder(); doc = db.parse(file); return doc; } public static Document loadDocument(String path) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); Document doc; DocumentBuilder db; db = dbf.newDocumentBuilder(); doc = db.parse(new File(path)); return doc; } public static Document loadDocument(InputStream is) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); Document doc; DocumentBuilder db; db = dbf.newDocumentBuilder(); doc = db.parse(is); return doc; } public static Document loadDocument(ReadableByteChannel in) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); Document doc; DocumentBuilder db; db = dbf.newDocumentBuilder(); doc = db.parse(Channels.newInputStream(in)); return doc; } }