|
Hi,
Try putting the file to be read in the directory
that contains the program that is starting your webserver. If this doesn't solve the problem, see if the output of this
statement works:
System.out.println(System.getProperty("user.dir")); //this is the dir where the
file be put ....
Hoping it helps.
Ravi
----- Original Message -----
Sent: Saturday, August 03, 2002 9:26
PM
Subject: Reading a file from
servlet.
Hello Everybody,
I just started writing servlets and I
have a question. How do you read a normal text file from a servlet. I know
this sounds silly but I have been trying to do this for sometime, but I
always get a file not found exception. I put this line of code into
the HelloWorld Servlet
BufferedReader bR = new
BufferedReader(new FileReader("response.txt"));
and it throws the
FilenotFoundException. I placed the text file in the same directory of the
class. I have checked the permissions of the file and all, they are ok
too.
Is there any special package or method that I should be
using??
Thanks in advance for
help.
--sai
___________________________________________________________________________ To
unsubscribe, send email to [EMAIL PROTECTED] and include in
the body of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources:
http://java.sun.com/products/servlet/external-resources.html LISTSERV
Help: http://www.lsoft.com/manuals/user/user.html
|