The same as before.
The dump of the new file is indistinguishable from that of the previous file.
The two short
s, each containing zero,
are written out as 32 zero bits.
Previously, an int
containing zero was written out as 32 zero bits.
There is nothing in the file that distinguishes one situation from the other.
A program that reads data from this file must be written with the knowledge of how the file was written. (Since I know how it was written, I put brackets under the bytes to show the intended groupings).
Here is an excerpt from the DataOutputStream
DataOutputStream, documentation
documentation.
public void writeBytes(String s) throws IOException — write the low eight bits of each character of the string.
This does not write the
entire String
object to the stream.
It merely writes bytes from the characters of the String.
A String
object (like all objects) is a big chunck of memory
with its own data, methods, and internal organization.
The writeBytes()
method just writes out the characters.
If the characters in a String are from the usual Western
alphabet, the writeBytes()
method writes
normal 8-bit ASCII.
(Review: )How is this different from a Writer
stream?