java从文件读取集合

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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从文件读取集合的主要内容,如果未能解决你的问题,请参考以下文章