First you need to call output.close() (or at least call output.flush() ) before opening the file again for input. This is probably the main cause of your problems.
Then you should not use FileReader or FileWriter for this, because it always uses the default encoding for the platform (which is often not UTF-8). From the docs for FileReader :
The constructors of this class assume that the default character encoding and default byte size are appropriate.
You have the same problem when using FileWriter . Replace this:
BufferedReader br = new BufferedReader(new FileReader("DirectionResponse.xml" ));
with something like this:
BufferedReader br = new BufferedReader(new InputStreamReader( new FileInputStream("DirectionResponse.xml"), "UTF-8"));
and similarly for fstream .
Ted hopp
source share