Code example for InputSource

Methods: setEncoding

0
                SAXParser sParser = factory.newSAXParser();
                XMLReader parser = sParser.getXMLReader();
                JSONSAXHandler jsonHandler = new JSONSAXHandler(JSONStream, verbose);
                parser.setContentHandler(jsonHandler);
                parser.setErrorHandler(jsonHandler);
                InputSource source = new InputSource(new BufferedInputStream(XMLStream));
 
                if (logger.isLoggable(Level.FINEST)) {
                    logger.logp(Level.FINEST, className, "transform", "Parsing the XML content to JSON");
                } 
 
                /**  
                 * Parse it. 
                 */ 
                source.setEncoding("UTF-8");
                parser.parse(source);                 
                jsonHandler.flushBuffer();
            } catch (javax.xml.parsers.ParserConfigurationException pce) {
                throw new SAXException("Could not get a parser: " + pce.toString());
            } 
        } 
Experience pair programming with AI  Get Codota for Java