I Know that binary files connot be read by text editors, thay can be read only by programs. but when I create binary files using java(bytes), I can open files and read it ? why that happens? In other words, I see a plain text rather than a sequence of zeros and ones. I know that in java there are byte-based streams and character-based streams. when I use byte-based streams such as FileOutputStream, the output is characters not bytes.
File file = new File("Myfile.dat"); // .txt or .bin
FileOutputStream fos = new FileOutputStream(file);
String data = "Hello, world";
fos.write(data.getBytes());
fos.close();
when I open Myfile.dat using notepad, I expect to see special characters or 0s and 1s but I can read the content "hello world". So I do not undrstand how byte-based streams store characters in binary format?