File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes In Java, how to read from a  specific line, given the line number? 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 » I/O and Streams
Bookmark "In Java, how to read from a  specific line, given the line number?" Watch "In Java, how to read from a  specific line, given the line number?" New topic
Author

In Java, how to read from a specific line, given the line number?

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi ,

In Java, how to read from a specific line, given the line number?

please suggest as how to do this .

Thanks

Ravi Kiran .


Save India From Corruption - Anna Hazare.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

You could read the file, line by line, until you are at the required line number.
The java.io.LineNumberReader can help you with that.

OCUP UML fundamental and ITIL foundation
youtube channel
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Unless all lines have the same fixed length, or you know the starting position of each line, reading the file line-by-line is the only way to do this.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
 
subject: In Java, how to read from a specific line, given the line number?
 
Similar Threads
Reading website text
Urgent Help Required Pls!!!! how to extract date from file.
how to read from given line number
command line arguments
read specific line from text file