public static BufferedReader getBufferedXMLReader ( InputStream stream , int xmlLookahead ) throws IOException { // create a buffer so we can reset the input stream BufferedInputStream input = new BufferedInputStream ( stream ) ; input . mark ( xmlLookahead ) ; // create object to hold encoding info EncodingInfo encoding = new EncodingInfo ( ) ; // call this method to set the encoding info XmlCharsetDetector . getCharsetAwareReader ( input , encoding ) ; // call this method to create the reader Reader reader = XmlCharsetDetector . createReader ( input , encoding ) ; // rest the input input . reset ( ) ; return getBufferedXMLReader ( reader , xmlLookahead ) ; }
Wraps an xml input xstream in a buffered reader specifying a lookahead that can be used to preparse some of the xml document resetting it back to its original state for actual parsing .