What modification will change this program so that it counts the number of bytes in a file?
Answer:
(1) Initialize a long variable to zero.
(2) Increment it in the loop body.
(3) Print it out after the loop is exited.
End of the Chapter
You have reached the end this chapter. You may wish to review the following. Click on a subject that interests you to go to where it was discussed.
- The abstract class InputStream
- The readInt() method.
- Problems with binary files.
- Advantages of binary files.
- Description of DataInputStream.
- Reading until end-of-file.
- Nested try{} blocks.
- input and output of bytes
- FileNotFoundException
The next chapter will discuss the File class
and input and output of structured data.