wood burning stoves*
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 Murach's Java Servlets and JSP this week in the Servlets 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading a file. Is it possible to choose the line to start from?
 
Similar Threads
could we ignore few lines from an BufferedReader input stream
How to stop a running task initiated by a servlet?
Route Finder Front End
Problem with renaming file after reading it
Comparing contents of a file with String[]