Given this code in Java:
FileOutputStream os = new FileOutputStream("/tmp/test.dat");
os.write(0x14);
os.write(0xfe);
os.write(0xae);
os.write(String.valueOf((char) 0x14).getBytes("UTF-8"));
os.write(String.valueOf((char) 0xfe).getBytes("UTF-8"));
os.write(String.valueOf((char) 0xae).getBytes("UTF-8"));
os.write("\u0014".getBytes("UTF-8"));
os.write("\u00fe".getBytes("UTF-8"));
os.write("\u00ae".getBytes("UTF-8"));
os.close();
Can somebody explain to me why the first 3 bytes in test.dat are
14 fe ae
while the output from the last 6 os.write()'s are
14 c3 be c2
Basically, I want to literally output the bytes 14 fe ae. I was storing these values as a String constant, and writing the value of these constants to a UTF-8 file, but 14 c3 be c2 was output instead. There's obviously a gap in my understanding in how these byte sequences are converted in Java.
Thanks!