这是我的代码:
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();
}
}
我收到一条警告new Scanner(a)
(我正在使用 jdk1.7.0_05 进行编译。):
Resource leak: '<unassigned Closeable value>' is never closed.
我做错了什么,或者这只是一个错误的警告?