Code example for StreamResult

Methods: getOutputStream

    public Object parse(Source source) throws IOException, SAXException, ParserConfigurationException, TransformerException {
        //TODO: use SAXResult to stream, need to figure out how to enable  
        // validation with transformer api 
        //SAXResult result = new SAXResult( handler ); 
        StreamResult result = new StreamResult( new ByteArrayOutputStream() );
        TransformerFactory tf = TransformerFactory.newInstance();
        Transformer tx = tf.newTransformer();
        tx.transform( source, result );
        return parse( new ByteArrayInputStream( ((ByteArrayOutputStream)result.getOutputStream()).toByteArray() ) );
     * Parses an instance documented defined by a sax input source. 
     * <p> 
     * The object returned from the parse is the object which has been bound to the root 
Experience pair programming with AI  Get Codota for Java