Code example for DefaultHandler

     * should use the {@link #setContentHandler(ContentHandler)} method to 
     * switch to a more usable underlying content handler. 
     * Also creates a dummy Metadata object to store phone numbers in. 
    protected PhoneExtractingContentHandler() { 
        this(new DefaultHandler(), new Metadata());
     * The characters method is called whenever a Parser wants to pass raw... 
     * characters to the ContentHandler. But, sometimes, phone numbers are split 
     * accross different calls to characters, depending on the specific Parser 
     * used. So, we simply add all characters to a StringBuilder and analyze it 
     * once the document is finished. 
    public void characters(char[] ch, int start, int length) throws SAXException {
        try { 
            String text = new String(Arrays.copyOfRange(ch, start, start + length));
Experience pair programming with AI  Get Codota for Java