Here you can find the source of parse(final InputStream in)
Parameter | Description |
---|---|
in | The input stream. |
Parameter | Description |
---|---|
SAXException | If there is a parsing error. |
IOException | If there is an I/O error. |
IllegalArgumentException | If there is a parser configuration error. |
public static Document parse(final InputStream in) throws SAXException, IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStream; import javax.xml.parsers.DocumentBuilder; 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 { /**/*w w w.jav a 2s .c om*/ * Parse an XML document. * * @param in * The input stream. * * @return A Document. * * @throws SAXException * If there is a parsing error. * @throws IOException * If there is an I/O error. * @throws IllegalArgumentException * If there is a parser configuration error. */ public static Document parse(final InputStream in) throws SAXException, IOException { return parse(new InputSource(in)); } /** * Parse an XML document. * * @param is * The input source. * * @return A Document. * * @throws SAXException * If there is a parsing error. * @throws IOException * If there is an I/O error. * @throws IllegalArgumentException * If there is a parser configuration error. */ public static Document parse(final InputSource is) throws SAXException, IOException { try { final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); return builder.parse(is); } catch (final ParserConfigurationException ex) { throw new IllegalArgumentException("DOM parser configuration error: " + ex.getMessage()); } } }