JDK之java.nio.file.Files

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/thebigdipperbdx/article/details/82860168

源码

public static List<String> readAllLines(Path path, Charset cs) throws IOException {
    try (BufferedReader reader = newBufferedReader(path, cs)) {
        List<String> result = new ArrayList<>();
        for (;;) {
            String line = reader.readLine();
            if (line == null)
                break;
            result.add(line);
        }
        return result;
    }
}

猜你喜欢

转载自blog.csdn.net/thebigdipperbdx/article/details/82860168