java - from OutputStream to a File Stream -
I want to save my DOM document as an XML file. I follow this tutorial:
So, this is my code:
... transformerfactor tFactory = transformerfacture New Instance (); Transformer Transformer = TFTC NEUT Transformers (); DOMSource Source = New DOMSource (Doctor); StreamResult Results = New Stream Result (System.out); Transformer. Transform (source, result);
But instead of system.out , I want to save a file in the result. how can I do this?
Use
New StreamResult (New FileOutputStream (.. .))
But you might want to use the Writer
, so that you are output to encoded characters, as long as StreamResult Unicode encoding, say UTF-8, contained.
Comments
Post a Comment