Java text file read all lines by Files

Description

Java text file read all lines by Files

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;

public class Main {
    public static void main(String[] args) throws IOException {
        List<String> lines = Files.readAllLines(Paths.get("Main.java"));
        for (String line : lines) {
            System.out.println(line);
        }//  www  . j a  v a  2 s. c  o  m
    }
}



PreviousNext

Related