Yes; the example program did this.
As far as the I/O system and hard disk are concerned, the program sends a stream of bytes and they are stored on the disk, one after another. There is no concept (at the electronic level) of "int" or "double" or "char". Its all "bytes" to the electronics. The example program did this:
dataOut.writeInt( 0 ); dataOut.writeDouble( 12.45 );
The hex dump shows the 12 bytes.
Remember that dumps such as this print two
characters to show the pattern in one byte.
Notice that nothing separates the bytes of the
int
from the bytes of the double
.
The six zeros at the very left are not part of the file. They are how the dump shows that the first byte displayed is byte number zero of the file.
The f's the end of the line show that some bit patterns
of the double
could also be interpreted
as characters.
Is it possible to tell just by looking at the bytes in a file what types the data are?