Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Eclipse Java警告:リソースリーク:「割り当てられていないクローズ可能な値」は決して閉じられません
try(FileChannel f = new RandomAccessFile(new File(p),"rw").getChannel();){}
漏れはどこですか?
リソースは RandomAccesFile です。このオブジェクトの新規作成を行っていますが、変数に保存していないため、randomAccesFile.close() を閉じることはできません。
これは無視しても問題ありません。
それ以降FileChannelもCloseable、FileChannel::close基礎となるストリームを閉じます。
FileChannel
Closeable
FileChannel::close