Given that I basically want to eliminate checked exception usage and transform them to runtime exceptions, I would normally be doing something like this:
try {
class IORuntimeException extends RuntimeException {
final IOException ioex;
public IORuntimeException(IOException ioex) {
this.ioex = ioex;
}
@Override
public String getMessage() {
return ioex.getMessage();
}
@Override
public StackTraceElement[] getStackTrace() {
return ioex.getStackTrace();
}
//@Override
// ...
}
(Full class available here, as produced by Eclipse "Generate Delegate Methods" macro.)
Usage:
try {
...
} catch (IOException ioex) {
throw new IORuntimeException(ioex);
}