package org.FileExamples.ReadingFiles; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class ReadFileExample01 { static void main() { try { File file = new File("example.txt"); Scanner reader = new Scanner(file); while(reader.hasNextLine()) { String line = reader.nextLine(); System.out.println(line); } reader.close(); } catch (FileNotFoundException e) { throw new RuntimeException(e); } } }