import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.Scanner; public class TestThing { public static void main(String[] args) throws IOException{ File file = new File ("thing.txt"); if(!file.exists()){ file.createNewFile(); BufferedWriter w = new BufferedWriter(new FileWriter(file)); for(int i = 0; i < 100000; i++){ w.append("Hello World"); w.newLine(); } w.flush(); w.close(); } Scanner s = new Scanner(file); file.delete(); int a = 0; while(s.hasNextLine()){ System.out.println(a++ + " | " + s.nextLine()); } System.out.println(a); } }