Code example for CharArrayReader

0
        if (header != null && header.length() > 10) {
            // Prepare a reader based on our input header string 
            int length = header.length();
            char c[] = new char[length];
            header.getChars(0, length, c, 0);
            Reader reader = new CharArrayReader(c);
 
            try { 
                // 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 
                XmlHandler dataHandler = new XmlHandler();
                xr.setContentHandler(dataHandler);
 
                // Parse the xml-data from our URL (ie Uri) 
                xr.parse(new InputSource(reader));