这是内存泄漏还是误报?
2022-09-01 00:30:24
这是我的代码:
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;
public class temp {
public static void main(String[] args) throws FileNotFoundException {
BufferedReader a = new BufferedReader(new FileReader("a"));
Scanner scanner = new Scanner(a).useDelimiter(",");
scanner.close();
}
}
我收到一个警告,上面写着(我正在编译jdk1.7.0_05)。new Scanner(a)
Resource leak: '<unassigned Closeable value>' is never closed.
是我做错了什么,还是这只是一个错误的警告?