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.InputStream; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; public class Main { /**//from w ww.j av a 2 s .c om * 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 (Exception e) { IOException thrown = new IOException(e.getMessage()); throw thrown; } } }