News for hackers. Stuff that matters.
Re:A Programming Idiom You've Never Heard Of by spullara on Wednesday January 04, 2012 @01:57AM (#3423124)
Java 7 has a implementation pattern built in for this now:

String readFirstLineFromFile(String path) throws IOException { try (BufferedReader br = new BufferedReader(new FileReader(path))) { return br.readLine(); } }

Anything that implements the AutoCloseable interface gets this behavior for free.

There are no comments on this comment yet.