Exception | Cause |
NumberFormatException |
You tried to convert a number from an illegal String form |
IOException |
Catch an IOException to get either of its subclasses below. |
FileNotFoundException |
The specified file didn't exist. |
EOFException |
Tried to read past end of file. |
MalformedURLException |
This can be generated if you are using the java.net package. |
try { UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel"); } catch (Exception e) { // Silently ignore -- there's nothing to be done. }Another example where exceptions are typically ignored is in calls to
sleep
.
try { Thread.sleep(DELAY); } catch (InterruptedException ignoredException) { // Silently ignore. This thread can never cause an exception. }If you do silently ignore exceptions, enclose only one call in the
try
clause; do not use larger blocks of code as suggested below.
Rather than silently ignoring exceptions, consider logging them to a file.
try
clauseif
tests because throwing and
catching exceptions is typically much slower.
e.printStackTrace();