FileNotFound exception
Posted
by
Pratik
on Stack Overflow
See other posts from Stack Overflow
or by Pratik
Published on 2012-10-14T15:23:30Z
Indexed on
2012/10/14
15:37 UTC
Read the original article
Hit count: 194
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 ?
© Stack Overflow or respective owner