Here you can find the source of fileToDOM(File file)
public static Document fileToDOM(File file) throws ParserConfigurationException, IOException, SAXException
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Document; import org.xml.sax.SAXException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.*; public class Main { public static Document fileToDOM(File file) throws ParserConfigurationException, IOException, SAXException { DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = dbfac.newDocumentBuilder(); return docBuilder.parse(file); }/*from w w w. j a v a 2 s . co m*/ }