public class MyIOTest { public static void main(String[] args) throws IOException{ MyIOTest myiotest = new MyIOTest(); BufferedWriter out = new BufferedWriter(new FileWriter("prova.out")); char[] ch = { 'a', 'b', 'c', 'd' }; char c = 32000; String s = "abcd"; out.write(ch); out.write(c); out.write(s); out.close(); } }
i used a file writer so the output stream is 16 bit char oriented (also java native char is 16 bit Unicode); but if i open prova.out file with an Hex editor this is what i view:
61 62 63 64-3F 61 62 63-64 - abcd?abcd
why FileWriter wrote Ascii chars instead of Unicode chars?
I think you have to go with a FileOutputStream. This way you have to convert your characters to unicode 'manually' before writing the code into the file, but at the end you should get your desired result.