FileOutputStream fos = new FileOutputStream(f, true);
FileChannel fileChannel = fos.getChannel();
FileWriter fileWriter = Channels.newWriter( fileChannel, Charset.forName("UTF-8").newEncoder(), -1 );
No, it's not a resource leak but the compiler isn't smart enough to figure that out.
When you close your
FileWriter, it closes the
FileChannel, which in turn closes the
This of course, may not be the case with different JVM's. I've only looked at the code in the Oracle's Java8
Since it's not stated as part of the public contract of
FileWriter, it's a good idea to explicitly close all streams you create.