OutputStreamWriter
java.io.OutputStreamWriter
If you like to write a stream with a certain Encoding (e.g. UTF-8), then the following example can help:
String lineSeparator = System.getProperty("line.separator"); OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("myfile.xml"), "UTF-8"); osw.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"+lineSeparator); osw.append("äöüßÄÖÜ"+lineSeparator); osw.flush(); osw.close();
Here InputStreamReader is written, how to read it again.