File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Reading a file. Is it possible to choose the line to start from? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Reading a file. Is it possible to choose the line to start from?" Watch "Reading a file. Is it possible to choose the line to start from?" New topic
Author

Reading a file. Is it possible to choose the line to start from?

Rudolph Ten
Greenhorn

Joined: Jan 23, 2002
Posts: 9
Is it possible to choose the line I want to start reading the file from? I am new to java.

I was using this code:
=========================
while((s = br.readLine()) != null) {
System.out.println(s);
totalLineReadInCnt++;
=========================
Thanks in advance
Rudy
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Rudolph,
The only I/O class that lets you start reading a file anywhere is the RandomAccessFile class. It provides a readLine method so you should be able to use it to start reading anywhere. I don't think you can tell it to skip so many lines though because the skipping only works with bytes.
Regards,
Manfred.
Rudolph Ten
Greenhorn

Joined: Jan 23, 2002
Posts: 9
Thanks Manfred....that did it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Reading a file. Is it possible to choose the line to start from?
 
Similar Threads
Route Finder Front End
Problem with renaming file after reading it
could we ignore few lines from an BufferedReader input stream
How to stop a running task initiated by a servlet?
Comparing contents of a file with String[]