/** * Use this variant when you aren't interested in encoding data, and just want to get a suitable * reader for incoming request. * * @param istream See <code>getCharsetAwareReader(InputStream, * EncodingInfo)</code>. */ public static Reader getCharsetAwareReader(InputStream istream) throws IOException, UnsupportedCharsetException { return getCharsetAwareReader(istream, new EncodingInfo()); }
/** * 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. * * @param stream The original xml stream. * @param xmlLookahead The number of bytes to support for parse. If more than this number of * bytes are preparsed the stream can not be properly reset. * @return The buffered reader. */ 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); }
encInfo.copyFrom(getEncodingName(b4, count)); String declEncoding = getXmlEncoding(reader);
encInfo = XmlCharsetDetector.getEncodingName(b4, count); response.setCharacterEncoding( encInfo.getEncoding() != null ? encInfo.getEncoding() : "UTF-8");
/** * Parses the info.xml file into a DOM. * * <p>This method *must* be called before any other methods. * * @param file The info.xml file. * @throws IOException In event of a parser error. */ public void read(File file) throws IOException { parentDirectory = file.getParentFile(); Reader reader = XmlCharsetDetector.getCharsetAwareReader(new FileInputStream(file)); try { coverage = ReaderUtils.parse(reader); } finally { reader.close(); } }
/** * Parses the servivces.xml file into a DOM. * * <p>This method *must* be called before any other methods. * * @param file The services.xml file. * @throws IOException In event of a parser error. */ public void read(File file) throws IOException { Reader reader = XmlCharsetDetector.getCharsetAwareReader(new FileInputStream(file)); try { serverConfiguration = ReaderUtils.parse(reader); global = null; contact = null; wfs = null; wms = null; wcs = null; } finally { reader.close(); } }
/** * Parses the catalog.xml file into a DOM. * * <p>This method *must* be called before any other methods. * * @param file The catalog.xml file. * @throws IOException In event of a parser error. */ public void read(Resource file) throws IOException { Reader reader = XmlCharsetDetector.getCharsetAwareReader(file.in()); try { catalog = ReaderUtils.parse(reader); } finally { reader.close(); } }
/** * Parses the info.xml file into a DOM. * * <p>This method *must* be called before any other methods. * * @param file The info.xml file. * @throws IOException In event of a parser error. */ public void read(Resource file) throws IOException { parentDirectory = file.parent(); Reader reader = XmlCharsetDetector.getCharsetAwareReader(file.in()); try { featureType = ReaderUtils.parse(reader); } finally { reader.close(); } }
requestXml = new BufferedReader(XmlCharsetDetector.getCharsetAwareReader( request.getInputStream()));