Much of the required machinery for writing into a file runs parallel to the required machinery for reading from a file.
First, you connect to an output file by creating an instance of the
FileOutputStream
class, also known as a file
output stream, for a specified file. The following is an example in which
the file specification happens to be "output.data"
, and the file
output stream is assigned to stream
:
File specification --* v ------------- FileOutputStream stream = new FileOutputStream("output.data");