I wanted to know the Apache library method IOUtils.closeQuitely does well with FileChannel. I see it takes Closeable as argument and FileChannel does implement it up in hierarachy. But can we face any issue down the line. Any experience one can share please.
Asked
Active
Viewed 194 times
0
-
Pls check this. [link](http://stackoverflow.com/questions/2268465/disposing-streams-in-java) – aksappy Feb 15 '13 at 06:11
1 Answers
0
I think it's OK if we use it as IOUtils.closeQuietly API suggests, ie double-close
FileChannel ch = null;
try {
ch = new FileInputStream("foo.txt").getChannel();
// process
ch.close();
} catch (Exception e) {
// error handling
} finally {
IOUtils.closeQuietly(ch);
}
But try-with-resources if Java 7 is available is a much cleaner way.

Evgeniy Dorofeev
- 133,369
- 30
- 199
- 275