I have a Web Project where I am using the following code:
try {
br1 = new BufferedReader(new FileReader("queryWords.txt"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Now for this, it is throwing me the following exception:
java.io.FileNotFoundException: queryWords.txt (The system cannot find the file specified)
(I am storing 'queryWords.txt' file in the Project Folder itself)
When I change my code to the following:
br1 = new BufferedReader(new FileReader("C://Users//Project//Demo//queryWords.txt"));
where I have given the full absolute path, it runs perfectly but when I change my project to a plane 'Java Project', the initial code works perfectly fine and I am not getting any exception.
So why this unexpected behavior is happening? When my project is just 'Java Project', I don't have to provide the full path but when I have the 'Dynamic Web Project', I am getting the error if I don't give the full absolute path of the file.
Note:I am using Eclipse IDE.