/** * @author lautturi.com * Java example: java read a text file using Scanner */ import java.util.*; import java.io.*; public class Lautturi { public static void main(String[] args) throws FileNotFoundException { File file = new File("test.txt"); Scanner sc = new Scanner(file); while (sc.hasNextLine()) System.out.println(sc.nextLine()); } }