嗨,我是java的新手。这是我的java代码:
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.BufferedReader;
public class readw {
public static void main(String[] args) throws IOException {
List<String> lines = new ArrayList<String>();
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader("C:\\run\\input.txt"));
String line = null;
while ((line = reader.readLine()) != null) {
lines.add(line);
}
} finally {
reader.close();
}
String[] array = lines.toArray();
}
}
当我试图编译它时,我得到了这种类型的错误:
line 8: can not find symbol List (L)and ArrayList(A)
我正在尝试获取我的文本文件的内容并希望将其设置为数组。