|
|
@@ -226,15 +226,26 @@ public class XMLResultAggregator extends Task implements XMLConstants { |
|
|
|
* @throws IOException thrown if there is an error while writing the content. |
|
|
|
*/ |
|
|
|
protected void writeDOMTree(Document doc, File file) throws IOException { |
|
|
|
OutputStream out = new FileOutputStream( file ); |
|
|
|
PrintWriter wri = new PrintWriter(new OutputStreamWriter(out, "UTF8")); |
|
|
|
wri.write("<?xml version=\"1.0\"?>\n"); |
|
|
|
(new DOMElementWriter()).write(doc.getDocumentElement(), wri, 0, " "); |
|
|
|
wri.flush(); |
|
|
|
wri.close(); |
|
|
|
// writers do not throw exceptions, so check for them. |
|
|
|
if (wri.checkError()){ |
|
|
|
throw new IOException("Error while writing DOM content"); |
|
|
|
OutputStream out = null; |
|
|
|
PrintWriter wri = null; |
|
|
|
try { |
|
|
|
out = new FileOutputStream( file ); |
|
|
|
wri = new PrintWriter(new OutputStreamWriter(out, "UTF8")); |
|
|
|
wri.write("<?xml version=\"1.0\"?>\n"); |
|
|
|
(new DOMElementWriter()).write(doc.getDocumentElement(), wri, 0, " "); |
|
|
|
wri.flush(); |
|
|
|
// writers do not throw exceptions, so check for them. |
|
|
|
if (wri.checkError()){ |
|
|
|
throw new IOException("Error while writing DOM content"); |
|
|
|
} |
|
|
|
} finally { |
|
|
|
if (wri != null) { |
|
|
|
wri.close(); |
|
|
|
out = null; |
|
|
|
} |
|
|
|
if (out != null) { |
|
|
|
out.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|