This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes servlets program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlets program" Watch "servlets program" New topic
Author

servlets program

Jeannette Ilieva
Greenhorn

Joined: Jan 10, 2001
Posts: 2
I want some explanation for this problem:
I write a servlets who reads from a file where write the employe
report(name,SSn,birthdate), I make a table name,SSN, birthdate(3 rows).
I read this file with: FileReader file = new FileReader("c:\s_test\data.txt");
file.readLine(name1.substring(0,20).trim());
file.readLine(SSN1.substring(0,10).trim());
file.readLine(birthdate.sustring(0,10).trim());
I have to write while loop but I don't know how.
Could somebody tell me how?
Thanks!
prakash muthu
Ranch Hand

Joined: Sep 06, 2000
Posts: 75
hi,
How you can read a local pc file thro servlet.
let me know your requirment
with regards
Prakash
(prakashem@rediffmail.com)


Prakash.M<BR>Bangalore- India<BR>(prakashem@rediffmail.com)
Sagar Surana
Greenhorn

Joined: Dec 23, 2000
Posts: 21
please ellaborate ur problem and there is no problem for getting file from local pc
please explain u want loop for what and ur purpose
with luv,

------------------
Sagar Surana
optimist


Sagar Surana<BR>optimist
Kevin Mukhar
Ranch Hand

Joined: Nov 28, 2000
Posts: 83
This code will do what you want. When using this code, the data.txt file must be in the same directory as the servlet:
InputStream in = getClass().getResourceAsStream(file);
InputStreamReader rin = new InputStreamReader(in);
BufferedReader bin = new BufferedReader(rin)
String line;
while (true) {
line = bin.readLine();
if (line == null) break;
//do something with line
}
Originally posted by Jeannette Ilieva:
I want some explanation for this problem:
I write a servlets who reads from a file where write the employe
report(name,SSn,birthdate), I make a table name,SSN, birthdate(3 rows).
I read this file with: FileReader file = new FileReader("c:\s_test\data.txt");
file.readLine(name1.substring(0,20).trim());
file.readLine(SSN1.substring(0,10).trim());
file.readLine(birthdate.sustring(0,10).trim());
I have to write while loop but I don't know how.
Could somebody tell me how?
Thanks!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlets program
 
Similar Threads
servlets
servlets(help)
servlets
Could somebody give some ideas?
servlet(delete)