go to previous page   go to home page   go to next page

Answer:

Yes, an IOException is a checked exception, and so must be caught or thrown to the caller. (More on this later.)


Example Run

C:\Programs>DIR

06/04/00  07:55p        <DIR>          .
06/04/00  07:55p        <DIR>          ..
06/04/00  07:55p                   693 WriteTextFile.class
06/04/00  07:55p                   475 WriteTextFile.java

C:\Programs>java  WriteTextFile

C:\Programs>DIR

06/04/00  07:56p        <DIR>          .
06/04/00  07:56p        <DIR>          ..
06/04/00  07:56p                   120 reaper.txt
06/04/00  07:55p                   693 WriteTextFile.class
06/04/00  07:55p                   475 WriteTextFile.java

C:\Programs>TYPE REAPER.TXT
Behold her, single in the field,
Yon solitary Highland Lass!
Reaping and singing by herself;
Stop here, or gently pass!

To see that the program worked, use the DIR command in the command-prompt window to look at the directory, or use the Windows file browser, Explorer.

Since it is a text file, you can use the TYPE command or the cat command (in Unix) to see it on the screen, or you can double-click it in Explorer.

The listing shows that the file reaper.txt contains 120 bytes, including end of line characters.

In the Unix (or Linux) command prompt window use ls -l to see a directory listing. Use cat reaper.txt to see the contents.


QUESTION 5:

Could you edit reaper.txt with a text editor?