I'm using DataOutputStream of Java IO in order to write to a file but when I execute the program, I don't get the correct output, instead, I get weird characters. -Although I have noticed that only writing strings using the writeUTF(String str) method works, even using writeBytes(String s) produces a weird character that's supposed to be space character- The code part of writing to file is below, any ideas on possible causes, maybe something related to encodings? Thanks in advance.
FileOutputStream fs= new FileOutputStream("Path/to/my/file");
DataOutputStream ds = new DataOutputStream(fs);
ds.writeBoolean(false);
ds.writeChar('A');
ds.writeInt(42);
ds.writeBytes("test1");
ds.writeUTF("test2");
fs.close();