Here you can find the source of parseDocument(Reader reader)
public static Document parseDocument(Reader reader) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.io.Reader; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.SAXException; public class Main { public static Document parseDocument(Reader reader) throws IOException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); try {/*w w w . j a v a2s.co m*/ return factory.newDocumentBuilder().parse(new InputSource(reader)); } catch (ParserConfigurationException | SAXException e) { throw new IOException(e); } } }