Here you can find the source of parse(InputStream is)
Parameter | Description |
---|---|
is | The stream to get the XML from. |
Parameter | Description |
---|---|
IOException | It there is an error creating the dom. |
public static Document parse(InputStream is) throws IOException
//package com.java2s; import java.io.IOException; import java.io.InputStream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.xml.sax.SAXException; public class Main { /**//from ww w. j ava 2 s .com * This will parse an XML stream and create a DOM document. * * @param is The stream to get the XML from. * @return The DOM document. * @throws IOException It there is an error creating the dom. */ public static Document parse(InputStream is) throws IOException { try { DocumentBuilderFactory builderFactory = DocumentBuilderFactory .newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); return builder.parse(is); } catch (FactoryConfigurationError e) { throw new IOException(e.getMessage(), e); } catch (ParserConfigurationException e) { throw new IOException(e.getMessage(), e); } catch (SAXException e) { throw new IOException(e.getMessage(), e); } } }