input file cannot be found
- by Eric Smith
I am just messing around with reading input files with java until I got stumped at the most basic of steps... finding the input file!
The input.txt file is in the same directory as my class file that is calling it yet eclipse still gives me an error that it cant be found:
"Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Unhandled exception type FileNotFoundException"
My code:
package pa;
import java.util.Scanner;
public class Project {
public static void main(String[] args) {
java.io.File file = new java.io.File("input.txt");
System.out.println(file.getAbsolutePath());
Scanner input = new Scanner(file);
}
}
input.txt is in the same package, same folder and everything. I'm confused :(