private Reader getReader ( InputSource s ) throws SAXException , IOException { Reader r = s . getCharacterStream ( ) ; InputStream i = s . getByteStream ( ) ; String encoding = s . getEncoding ( ) ; String publicid = s . getPublicId ( ) ; String systemid = s . getSystemId ( ) ; if ( r == null ) { if ( i == null ) i = getInputStream ( publicid , systemid ) ; // i = new BufferedInputStream(i); if ( encoding == null ) { r = theAutoDetector . autoDetectingReader ( i ) ; } else { try { r = new InputStreamReader ( i , encoding ) ; } catch ( UnsupportedEncodingException e ) { r = new InputStreamReader ( i ) ; } } } // r = new BufferedReader(r); return r ; }
Buffer both the InputStream and the Reader