Code example for Logger

Methods: enteringexitingisLoggablelogp

     * @throws IOException Thrown if an IO error occurs. 
    public static void toXml(InputStream JSONStream, OutputStream XMLStream, boolean verbose)
    throws IOException 
        if (logger.isLoggable(Level.FINER)) {
            logger.entering(className, "toXml(InputStream, OutputStream)");
        if (XMLStream == null) {
            throw new NullPointerException("XMLStream cannot be null");
        } else if (JSONStream == null) {
            throw new NullPointerException("JSONStream cannot be null");
        } else { 
            if (logger.isLoggable(Level.FINEST)) {
                logger.logp(Level.FINEST, className, "transform", "Parsing the JSON and a DOM builder.");
            try { 
                //Get the JSON from the stream. 
                JSONObject jObject = new JSONObject(JSONStream);
                //Create a new document 
                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                DocumentBuilder dBuilder = dbf.newDocumentBuilder();
                Document doc = dBuilder.newDocument();
                if (logger.isLoggable(Level.FINEST)) {
                    logger.logp(Level.FINEST, className, "transform", "Parsing the JSON content to XML");
                convertJSONObject(doc, doc.getDocumentElement(), jObject, "jsonObject");
                //Serialize it. 
                TransformerFactory tfactory = TransformerFactory.newInstance();
                Transformer serializer  = null;
                if (verbose) {
                    serializer = tfactory.newTransformer(new StreamSource( new StringReader(styleSheet) ));;
                } else { 
                    serializer = tfactory.newTransformer();
                Properties oprops = new Properties();
                oprops.put(OutputKeys.METHOD, "xml");
                oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
                oprops.put(OutputKeys.VERSION, "1.0");
                oprops.put(OutputKeys.INDENT, "true");
                serializer.transform(new DOMSource(doc), new StreamResult(XMLStream));
            } catch (Exception ex) {
                IOException iox = new IOException("Problem during conversion");
                throw iox;
        if (logger.isLoggable(Level.FINER)) {
            logger.exiting(className, "toXml(InputStream, OutputStream)");
     * Method to take an input stream to an JSON document and return a String of the XML format.   
Experience pair programming with AI  Get Codota for Java