I've read somewhere that this could be improved:
try { InputStream input = new FileInputStream("myFile.txt"); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); }
to:
try { InputStream input = new FileInputStream("myFile.txt"); } catch (FileNotFoundException e) { e.printStackTrace(); // esto es opcional, obviamente throw new RuntimeException(e); }
This way, we relaunching the exception as a RuntimeException our method doesn't have to declare any throws FileNotFoundException (at least for this example) and if the error does happen we'll see it immediately.
What are your comments on it?