The write()
method writes a single byte to file. Its parameter is an int, but that int is assumed to be in the range [0, 255].
If you want to write a full 4-byte int to file, use the writeInt()
method. Otherwise, to retrieve just the value 0 again, read one byte from the file using read()
.
As a side note, RandomAccessFile can handle both reads and writes, so you should use it for both.