import java.io.*;
      import java.nio.charset.StandardCharsets;
      import java.nio.file.*;
      import java.util.*;
      
      public static List<String> readAllLinesInFile(String fileName)
      {
        List<String> lines = Collections.emptyList();
        try
        {
          lines =
            Files.readAllLines(Paths.get(fileName), StandardCharsets.UTF_8);
        }
        catch (IOException e)
        {
          e.printStackTrace();
        }
        return lines;
      }
      
      Java language logo

      Read a file line by line

      java
      file
      Java Public Recipes

      Read a file line by line

      Java function to read a file line by line.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.