It’s my first time posing a question here. I would like to know which constructor is better in terms of performance for a large xml dom to be written to a test.xml file:
new StreamResult(new BufferedWriter(new OutputStreamWriter(new FileOutputStream("test.xml"), "UTF-8")))
Or
new StreamResult(new FileOutputStream("test.xml"))
Regarding setting the UTF-8 encoding, what happens in the second case where it’s not specified for an OutputStream? (Edit: This is answered but not the performance part yet)
StreamResult Constructor JavaDoc Link
Thanks
Encoding is done through Transformer. The Transformer may use instructions contained in the transformation instructions to control the encoding.