Sam Adamsh
Sam Adamsh

Reputation: 3391

eclipse java resource leak

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

Answers (2)

gvaish
gvaish

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

Chuidiang
Chuidiang

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

Related Questions