,
How To Write Own Checked Exception In Java. Common checked exceptions defined in the java.lang package: For example, consider the following java program that opens the file at location “c:\test\a.txt” and prints the first three lines of it.

You can do this in one of two ways. /** * my custom exception class. The code below shows the fileinputstream method from the java.io package with a red line underneath.