Hi, On Thu, Feb 19, 2009 at 2:00 PM, <[email protected]> wrote: > + // make sure close is only called once, otherwise HDFS complains > + // and throws an IOException :-/ > + return new FilterInputStream(fs.open(path)) { > + > + boolean closed = false; > + > + public void close() throws IOException { > + if (!closed) { > + try { > + super.close(); > + } finally { > + closed = true; > + } > + } > + } > + };
Another one of my Commons IO hints, the AutoCloseInputStream class [1] nicely handles this case. [1] http://commons.apache.org/io/api-release/org/apache/commons/io/input/AutoCloseInputStream.html BR, Jukka Zitting
