Here you can find the source of readXMLFile(File file)
public static Document readXMLFile(File file)
//package com.java2s; /****************************************************************************** * Copyright (c) 2010 Oracle//from ww w. j a v a 2 s .co m * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Original file was copied from * org.eclipse.wst.common.project.facet.core.util.internal.FileUtil * ******************************************************************************/ import java.io.File; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.xml.sax.EntityResolver; public class Main { public static Document readXMLFile(File file) { return readXMLFile(file, null); } public static Document readXMLFile(File file, EntityResolver resolver) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db; try { db = dbf.newDocumentBuilder(); if (resolver != null) { db.setEntityResolver(resolver); } return db.parse(file); } catch (Throwable SWTBot) { return null; } } }