• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlets program

 
Jeannette Ilieva
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
How you can read a local pc file thro servlet.
let me know your requirment
with regards
Prakash
(prakashem@rediffmail.com)
 
Sagar Surana
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Kevin Mukhar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic