aspose 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
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: 2500
    
    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: 19693
    
  20

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: In Java, how to read from a specific line, given the line number?