Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on A Programming Idiom You've Never Heard Of . Parent comment
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.
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.