Here you can find the source of readXml(String path)
private static Document readXml(String path) throws IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; public class Main { private static Document readXml(String path) throws IOException { File in = new File(path); if (!in.exists()) return null; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try {//w ww . jav a2 s .co m DocumentBuilder db = dbf.newDocumentBuilder(); return db.parse(in); } catch (IOException ex) { throw ex; } catch (Throwable err) { throw ((IOException) new IOException("Failed to load XML " + in.getPath()).initCause(err)); } } }