out = new OutputStreamWriter(stream, "UTF8");
out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
if (xslUri.length() > 0) {
out.write("<?xml-stylesheet type=\"text/xsl\" href=\"" + xslUri + "\"?>\n\n");
}
new DOMElementWriter().write(buildElement.element, out, 0, "\t");
out.flush();
} catch (IOException exc) {
throw new BuildException("Unable to write log file", exc);
} finally {
FileUtils.close(out);