Here you can find the source of parseXMLFromStream(InputStream stream)
Parameter | Description |
---|---|
stream | Input stream containing valid XML. |
Parameter | Description |
---|---|
Exception | Unspecified exception. |
public static Document parseXMLFromStream(InputStream stream) throws Exception
//package com.java2s; /**/*from w ww. j a va2s. com*/ * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. * If a copy of the MPL was not distributed with this file, You can obtain one at * http://mozilla.org/MPL/2.0/. * * This Source Code Form is also subject to the terms of the Health-Related Additional * Disclaimer of Warranty and Limitation of Liability available at * http://www.carewebframework.org/licensing/disclaimer. */ import java.io.InputStream; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; public class Main { /** * Parses XML from an input stream. * * @param stream Input stream containing valid XML. * @return XML document. * @throws Exception Unspecified exception. */ public static Document parseXMLFromStream(InputStream stream) throws Exception { Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(stream); stream.close(); return document; } }