Catch block variable warning in Java
Log the exception. It is always useful anyway when chasing a bug.
There's no clean way to "mark ex
as used" in Java, except by using it.
Note, however that according to its documentation a FileNotFoundException
can also be thrown when "[...] the file does exist but for some reason is inaccessible, for example when an attempt is made to open a read-only file for writing."
Therefore I suggest you do use the exception by also printing message from the exception.
I'm aware that this doesn't answer the general question, but I can hardly think of an exception of which I wouldn't at least log some information when it happens.
Use the @SuppressWarnings("unused")
annotation.
See also:
- Annotations tutorial
- Supported Values for @SuppressWarnings