public String getSortedXml ( Document newDocument ) { try ( ByteArrayOutputStream sortedXml = new ByteArrayOutputStream ( ) ) { BufferedLineSeparatorOutputStream bufferedLineOutputStream = new BufferedLineSeparatorOutputStream ( lineSeparatorUtil . toString ( ) , sortedXml ) ; XMLOutputter xmlOutputter = new PatchedXMLOutputter ( bufferedLineOutputStream , indentBlankLines ) ; xmlOutputter . setFormat ( createPrettyFormat ( ) ) ; xmlOutputter . output ( newDocument , bufferedLineOutputStream ) ; bufferedLineOutputStream . close ( ) ; return sortedXml . toString ( encoding ) ; } catch ( IOException ioex ) { throw new FailureException ( "Could not format pom files content" , ioex ) ; } }
Returns the sorted xml as an OutputStream .