FILE_NAME是什么,为啥没说。
package zh.codegym.task.task15.task1525;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/*
static 块中的文件
*/
public class Solution {
public static List<String> lines = new ArrayList<>();
static
{
BufferedReader reader = null;
try{
reader = new BufferedReader(new FileReader(Statics.FILE_NAME));
}catch(FileNotFoundException e){
e.printStackTrace();
}
while(true)
{
try {
String s = reader.readLine();
if(s == null || s.isEmpty() ) break;
lines.add(s);
}catch(IOException e){
e.printStackTrace();
}finally{
try{
reader.close();
}catch(IOException e){
e.printStackTrace();
}
}
}
}
public static void main(String[] args) {
System.out.println(lines);
}
}