Could a byte read from a file by
be written to another file by
Yes. Both methods use the same part of an
The next example program is a file copy program.
The text file copy program
(of two chapters ago)
did character-based IO
It could not be used for binary files.
The new copy program will do byte-oriented IO
and will work with any file.
The program is invoked from the command line, like this:
C:\Programs > java copyBytes sourceFile to destinationFile
As with the previous program, the "to" argument is there to ensure that the user has the files in the correct order. The program operates by reading the original file one byte at a time and writing to the destination file one byte at a time.