- Javax.xml.bind classes
- Home
- Binder
- DatatypeConverter
- JAXB
- JAXBContext
- JAXBElement
- JAXBElement.GlobalScope
- JAXBIntrospector
- Marshaller.Listener
- SchemaOutputResolver
- Unmarshaller.Listener
- Javax.xml.bind.util classes
- JAXBResult
- JAXBSource
- ValidationEventCollector
- Javax.xml.parsers classes
- DocumentBuilder
- DocumentBuilderFactory
- SAXParser
- SAXParserFactory
- Javax.xml.soap classes
- AttachmentPart
- MessageFactory
- MimeHeader
- MimeHeaders
- SAAJMetaFactory
- SOAPConnection
- SOAPConnectionFactory
- SOAPFactory
- SOAPMessage
- SOAPPart
- Javax.xml.validation classes
- Schema
- SchemaFactory
- TypeInfoProvider
- Validator
- ValidatorHandler
- Javax.xml.xpath classes
- XPathConstants
- XPathFactory
- Java Useful Resources
- Java - Quick Guide
- Java - Useful Resources
Javax.xml.parsers.SAXParser.reset() Method
Description
The Javax.xml.parsers.SAXParser.reset() method resets this SAXParser to its original configuration.
SAXParser is reset to the same state as when it was created with SAXParserFactory.newSAXParser(). reset() is designed to allow the reuse of existing SAXParsers thus saving resources associated with the creation of new SAXParsers.
Declaration
Following is the declaration for Javax.xml.parsers.SAXParser.reset() method
public void reset()
Parameters
NA
Return Value
This method does not return a value.
Exception
UnsupportedOperationException − When Implementations do not override this method
Example
For our examples to work, a xml file named Student.xml is needed in our CLASSPATH. The contents of this XML are the following −
<?xml version = "1.0" encoding = "UTF-8" standalone = "yes"?> <student id = "10"> <age>12</age> <name>Malik</name> </student>
The following example shows the usage of Javax.xml.parsers.SAXParser.reset() method.
package com.tutorialspoint; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.HandlerBase; public class SaxParserDemo { public static void main(String[] args) { // create a new SAXParserFactory SAXParserFactory factory = SAXParserFactory.newInstance(); // create a new DefaultHandler HandlerBase handler = new HandlerBase() { // define what the parser does when it finds a character public void characters(char[] ch, int start, int length) { // print the characters System.out.println("" + new String(ch, start, length)); } }; try { // get a new SAXParser SAXParser parser = factory.newSAXParser(); // parse the file parser.parse("Student.xml", handler); // reset the parser parser.reset(); System.out.println("Parser is reseted."); } catch (Exception ex) { ex.printStackTrace(); } } }
If we compile the code and execute it, this will produce the following result −
12 Malik Parser is reseted.
To Continue Learning Please Login
Login with Google