Code example for ByteArrayBuffer

Methods: buffer, length

0
import javax.xml.parsers.SAXParserFactory; 
 
public class CustomDataParser { 
 
    public String parseXML(ByteArrayBuffer xmlData) {
        if (xmlData != null && xmlData.length() > 0) {
            try { 
                // Prepare a stream based on our input xml string 
                ByteArrayInputStream bais = new ByteArrayInputStream(xmlData.buffer(), 0,
                        xmlData.length());
 
                // Get a SAXParser from the SAXPArserFactory 
                SAXParserFactory spf = SAXParserFactory.newInstance();
                SAXParser sp = spf.newSAXParser();
 
                // Get the XMLReader of the SAXParser we created 
                XMLReader xr = sp.getXMLReader();
                // Create a new ContentHandler and apply it to the XML-Reader 
                CustomDataXmlHandler triggerHandler = new CustomDataXmlHandler();
                xr.setContentHandler(triggerHandler);