public static Document readXML(File file) {
if (file == null) {
throw new NullPointerException("Xml file is null !");
}
if (file.exists() == false) {
throw new UtilException("File [" + file.getAbsolutePath() + "] not a exist!");
}
if (file.isFile() == false) {
throw new UtilException("[" + file.getAbsolutePath() + "] not a file!");
}
try {
file = file.getCanonicalFile();
} catch (IOException e) {
}
final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
final DocumentBuilder builder = dbf.newDocumentBuilder();
return builder.parse(file);
} catch (Exception e) {
throw new UtilException("Parse xml file [" + file.getAbsolutePath() + "] error!", e);
}
}