Home Segments Top Top Previous Next

480: Mainline

Whenever you create FileInputStream instances, you must also tell Java what to do in the event that a lamentable input–output error occurs: for example, your program might try to attach a file input stream to a file that does not exist.

In such lamentable situations, Java is said to throw an exception. For example, Java throws an exception that is an instance of the FileNotFoundException class whenever you try to connect a file input stream to a file that does not exist.