Im trying to read a simple text file with contents input.txt
Line 1
Line 2
Line 3
But it always goes to the exception and prints Error.
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[]){
        List<String> text = new ArrayList<String>();
        try{
            BufferedReader reader = new BufferedReader(new FileReader("input.txt"));
            for (String line; (line = reader.readLine()) != null; ) {
                 text.add(line);
            }
            System.out.println(text.size()); //print how many lines read in
            reader.close();
        }catch(IOException e){
            System.out.println("ERROR");
        }
    }   
}
Im using Eclipse as my IDE if that makes a difference. I've tried this code on http://www.compileonline.com/compile_java_online.php and it runs fine, why wont it run in Eclipse?
 
     
     
    