java-byte uses all the values ββthat can be represented by the 8-bit memory in which it is stored, so there is no place for the value of the "invalid" byte by default, and you must choose it yourself (for example, 1 if you use only positive values ) If you need all byte values, you can use a larger data type, such as short, to represent invalid values.
Alternatively, you can independently track free / unused areas in your file, so you need to store information about free and used addresses in your file, but you can still read the write bytes.
source share