This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
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 Head First Android this week in the Android 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: 2541
    
  10

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
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20044
    
  30

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 - OCEJPAD 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?
 
It's not a secret anymore!