Here you can find the source of readXML(InputStream inputStream, EntityResolver resolver, ErrorHandler error)
public static Document readXML(InputStream inputStream, EntityResolver resolver, ErrorHandler error)
//package com.java2s; /****************************************************************************** * Copyright (c) 2010 Oracle//from w ww. j a v a 2s . 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.ByteArrayInputStream; import java.io.InputStream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.xml.sax.EntityResolver; import org.xml.sax.ErrorHandler; public class Main { public static Document readXML(InputStream inputStream, EntityResolver resolver, ErrorHandler error) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db; try { db = dbf.newDocumentBuilder(); if (resolver != null) { db.setEntityResolver(resolver); } if (error != null) { db.setErrorHandler(error); } return db.parse(inputStream); } catch (Throwable SWTBot) { return null; } } public static Document readXML(String content) { return readXML(new ByteArrayInputStream(content.getBytes()), null, null); } }