Here you can find the source of createDocument()
public static Document createDocument() throws ParserConfigurationException, IOException, SAXException
//package com.java2s; //License from project: Apache License import org.w3c.dom.Document; import org.xml.sax.SAXException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.IOException; import java.io.InputStream; public class Main { static DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); public static Document createDocument(InputStream inputStream) throws ParserConfigurationException, IOException, SAXException { DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); return dBuilder.parse(inputStream); }//from ww w. j ava 2 s . c om public static Document createDocument() throws ParserConfigurationException, IOException, SAXException { DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); return dBuilder.newDocument(); } }