Reputation: 3391
Eclipse java warning: Resource leak: ''unassigned Closeable value' is never closed
try(FileChannel f = new RandomAccessFile(new File(p),"rw").getChannel();){}
Where is the leak?
Upvotes: 3
Views: 1852
Reputation: 9404
You can safely ignore this.
Since FileChannel
is also Closeable
and FileChannel::close
also does a close on the underlying stream.
Upvotes: 1
Reputation: 1055
The resourece is RandomAccesFile. You are doing a new of this object, but you don´t store it into any variable, so you can never close it randomAccesFile.close().
Upvotes: 2