Here you can find the source of parse(DefaultHandler handler, InputStream in)
Parameter | Description |
---|---|
handler | the SAX event handler |
in | the input stream containing the XML to be parsed |
public static void parse(DefaultHandler handler, InputStream in) throws IOException, ParserConfigurationException, SAXException
//package com.java2s; import org.xml.sax.*; import org.xml.sax.helpers.DefaultHandler; import java.io.*; import javax.xml.parsers.*; public class Main { /** The factory from whence we obtain XMLReader objects */ protected static SAXParserFactory _pfactory; /**//from w w w. j a v a 2 s . com * Parse the XML data in the given input stream, using the * specified handler object as both the content and error handler. * * @param handler the SAX event handler * @param in the input stream containing the XML to be parsed */ public static void parse(DefaultHandler handler, InputStream in) throws IOException, ParserConfigurationException, SAXException { XMLReader xr = _pfactory.newSAXParser().getXMLReader(); xr.setContentHandler(handler); xr.setErrorHandler(handler); xr.parse(new InputSource(in)); } }