Read line with Scanner
This code reads the file line by line. public static void readFileByLine(String fileName) { try { File file = new File(fileName); Scanner scanner = new Scanner(file); while (scanner.hasNext()) { System.out.println(scanner.next()); } scanner.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } } You can also set a delimiter as a line separator and then perform the same. …