I'm associated with this Butler IO, it's basically a helper for getting and writing resources.
Does things like this:
String fromClasspath = ButlerIO.textFrom( "res:articles/steve_jobs.txt" );
The workings of textFrom basically come from this method.
public static byte [] bytesFrom(InputStream inputStream) {
ByteArrayOutputStream out = new ByteArrayOutputStream(BUFFER_SIZE);
try {
copy(inputStream, out);
return out.toByteArray();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
The project wasn't up a day and a complaint was received about catching the checked and re-throw a runtime exception. In their words; "... throwing an unchecked exception here is just pampering the user in false safety. Checked exceptions are there for a good reason"
This project was built to help make clean code and has followed Bruce Eckel's thoughts on this subject of exceptions.
I can't think of a time when you can recover from an IOException, and this way can identify programmer errors early and clearly at runtime. The utility doesn't enforce you to catch any exception, which makes for cleaner code...right?
Isn't the point that any error handling be the choice of the caller; Butler can't do anything about a missing file, and doesn't presume to know what the caller wants to do either.
Have I got this wrong? I don't think so! But I would appreciate some feedback from you guys. Thanks.
