Code example for StringWriter

Methods: getBuffer

0
        } 
        return subsystemParser;
    } 
 
    private String marshall(SubsystemParser subsystemParser) throws Exception {
        StringWriter stringWriter = new StringWriter();
        XMLOutputFactory factory = XMLOutputFactory.newInstance();
        FormattingXMLStreamWriter writer = new FormattingXMLStreamWriter(factory.createXMLStreamWriter(stringWriter));
        try { 
            Assert.assertNotNull(subsystemParser.getSubsystem());
            writer.writeStartDocument();
            subsystemParser.getSubsystem().marshall(writer);
            writer.writeEndDocument();
        } finally { 
            writer.close();
        } 
 
        //System.out.println(stringWriter.getBuffer().toString()); 
        return stringWriter.getBuffer().toString();
    } 
 
    private String trimOriginalXml(URL url) throws Exception {
        StringBuilder sb = new StringBuilder();
        BufferedReader reader = new BufferedReader(new FileReader(new File(url.toURI())));
Connect your IDE to all the code out there  Get Codota for Java