首页 > 代码库 > java从文件读取集合

java从文件读取集合

public class ReadList {

    public static List<String> readList(String file) throws IOException {
        List<String> li = new ArrayList<String>();
        BufferedReader reader = new BufferedReader(new FileReader(file));
        String s = null;
        while (null != (s = reader.readLine())) {
            li.add(s);
        }
        reader.close();
        return li;
    }
}

 

java从文件读取集合