Java按行读取文件工具类

import java.io.*;
import java.util.*;

public class FileReadUtil {
    public static List<String> ReadFile(String file) {
        List<String> list = new ArrayList<>();
        String str;
        try {
            LineNumberReader reader = new LineNumberReader(new FileReader(file));
            while ((str = reader.readLine()) != null) {
                if (!str.isEmpty()) {
                    list.add(str);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return list;
    }
} 
原文地址:https://www.cnblogs.com/linyufeng/p/13625466.html