working with text read text by lines

Solutions on MaxInterview for working with text read text by lines by the best coders in the world

showing results for - "working with text read text by lines"
Yannic
15 May 2020
1public class FileReader {
2
3    public void readLines(BufferedReader reader) throws IOException {
4        String line;
5        while ((line = reader.readLine())  != null) {
6            System.out.println(line);
7        }
8    }        
9
10    public static void main(String[] args) {
11        try (BufferedReader reader = Files.newBufferedReader(Path.of("data.csv"))) {
12            new FileReader().readLines(reader);
13        } catch (IOException ioe) {
14            throw new IllegalStateException("Can not read file", ioe);
15        }
16    }
17}