I’m creating a flow service which takes in an xml node as input and need to write its contents to a file. Currently, the node is being converted to a string, and then written to a file, but due to the size of the files, this is probably not the best solution.
Review the large file handling approaches for information on using a nodeIterator to iterate over a large XML document. You could use that approach to read a preset number of elements or bytes and use java IOStreams to write to your output file. This may be a bit (ok, maybe a lot) slower, but will have a much smaller memory footprint.