Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File Reader

 
Raghavendra U Ganiga
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

i want know how to read a particular line in a text file using JSP's file reader option.

Raghav
:roll:
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Raghavendra U Ganiga
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
it may be any type of file reader or buffer reader option which is suitable.

Regards
Raghav
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP has no special facilities for reading files once you have determined their path. So I've moved this to the I/O forum.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming lines of unequal length, the only way to read a particular line in a file in Java is to read all the data before the line, then read the line. For example,



I've skipped error handling entirely here -- you want to check readLine() for a null return whenever you call it, because it means you've hit end-of-file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic