package com.companyname.common.test; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; /** * @Description * @Author Created by shusheng. * @Email shusheng@yiji.com * @Date 2018/12/2 */ public class FileToArrayListDemo { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new FileReader("a.txt")); ArrayList<String> array = new ArrayList<String>(); String line = null; while((line=br.readLine())!=null){ array.add(line); } br.close(); for(String s:array){ System.out.println(s); } } }
原文:https://www.cnblogs.com/zuixinxian/p/10086907.html