0

hi!
I m using netbeans 6.5.1 i am trying to read a text file from a jsp using the code

BufferedReader input = new BufferedReader(new FileReader("contactus.txt"));

this file "contactus.txt" is placed in the same folder (ie web folder) as the jsp file. but the browser is giving the error
file not found. pls help.....
i m not sure where the txt file should be placed in netbeans project to make it find it or should i try a different way to give url?

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by memegha123
0

Welcome memegha123.

getRealPath() translate a local URL into a path name in the local file system.

String path=application.getRealPath("/contactus.txt");
BufferedReader input = new BufferedReader(new FileReader(path));
0

thanx a lot it seems to work i m no longer getting that exception file not found

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.