Answers for "Working with text - read text by lines"

0

Working with text - read text by lines

public class FileReader {

    public void readLines(BufferedReader reader) throws IOException {
        String line;
        while ((line = reader.readLine())  != null) {
            System.out.println(line);
        }
    }        

    public static void main(String[] args) {
        try (BufferedReader reader = Files.newBufferedReader(Path.of("data.csv"))) {
            new FileReader().readLines(reader);
        } catch (IOException ioe) {
            throw new IllegalStateException("Can not read file", ioe);
        }
    }
}
Posted by: Guest on April-25-2021

Code answers related to "Working with text - read text by lines"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language