Code example for StringWriter

Methods: getBuffertoString

0
        assertTrue(Arrays.equals(expected, actual));
    } 
     
    public void testSerializeToChars() throws Exception { 
        OMSourcedElement element = createSourcedElement("test", UTF8);
        StringWriter sw = new StringWriter();
        element.serialize(sw);
        String actual = sw.toString();
        sw.getBuffer().setLength(0);
        // Compare with the behavior of an equivalent OMElement 
        element.cloneOMElement().serialize(sw);
        String expected = sw.toString();
        assertEquals(expected, actual);
    } 
} 
Connect your IDE to all the code out there  Get Codota for Java