I need to output large amounts of data to an XML file using JAXB. My question is a follow-up question to:
Can JAXB Incrementally Marshall An Object?
In Blaise Doughan's answer he stated to first manually write the opening xml tag followed by the repeated elements (which must be root elements) and then the closing tag. His example outputted to the console (System.out
) and not to a file. If a FileOutputStream
was used instead; what is the best way to ensure the XML Declaration (<?xml version="1.0" encoding="UTF-8" standalone="true"?>
) is written to the file before the opening xml tag? I would not think the best answer would be to manually write it as well.
I reviewed the following answer:
How to stream large Files using JAXB Marshaller?
However, I would think JAXB would have a solution to this problem without using an external interface to do so.