Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reading text file doesn't work...

Status
Not open for further replies.

GoSooJJ

Programmer
Feb 24, 2001
76
US
hi again,
i just tested reading text file, but i'm not able to read a file... here is simple jsp code for make sure it found a file and read...

<%@ page language=&quot;java&quot; import=&quot;java.io.*&quot; %>
<%@ page language=&quot;java&quot; import=&quot;java.util.*&quot; %>
<%
try {
File txtFile = new File(&quot;stdnet.txt&quot;);
FileReader fr = new FileReader(txtFile);
out.println(&quot;found file!&quot;);
} catch (IOException e) {
out.println(&quot;error!&quot;);
}
%>

what is wrong here? please help...
JJ //
 
Ok, now i took try/catch function out and got a error as this.

500 Servlet Exception
java.io.FileNotFoundException: stdnet.txt (The system cannot find the file specified)

the file is in same directory. i renamed file name, but same error. howcome, it says 'can not find file'???

pls help...
JJ //
 
Try giving the full path and filename.

Also, put your try catch back and just add the following line to your catch block, makes for easier debugging:
e.printStackTrace();
 
Thx so much wushutwist!
U're right, i had to add full path and filename.

wushutwist, i have an another question if you can help me. How can outside user this function? I mean, assume the client has the file and trying to upload text file and server reads it and copy to database. I already finish on server local text file but not client. Any idea on this?

again, thx...
JJ //
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top