Can a value from an int
variable
be written to a file without translating it into characters?
Yes.
A Java int
uses patterns of 32 bits to represent integers.
The exact pattern from an int
can be written to four bytes
of a file.
OutputStream is an abstract class from which all
byte-oriented output streams descend.
Its descendant classes are used for general-purpose
(non-character output).
These streams
write groups of bytes to output destinations.
Java writes the same format for primitive types on all platforms.
The data in a binary file can be read by Java programs running
on any platform.
A FileOuputStream connects an output stream of bytes
to a file. A DataOuputStream can be connected
to a FileOutputStream
to provide
methods that are convenient for writing various data types.