FileNotFound exception
- by Pratik
I am trying to read a file in a servlet. I am using eclipse IDE.
I get a FileNotFoundException if I provide relative file name.
List<String> ls=new ArrayList<String>();
Scanner input = new Scanner(new File("Input.txt"));
while(input.hasNextLine()) {
ls.add(input.nextLine());
}
The same code works if I put the absolute path like this:
Scanner input = new Scanner(new File("F:/Spring and other stuff/AjaxDemo/src/com/pdd/ajax/Input.txt"));
The Java file and text file are there in the same folder.
Does it searches text file in some other folder ?