?
Solved

Is there any way to tail a File like a tail -f?

Posted on 2002-04-02
6
Medium Priority
?
239 Views
Last Modified: 2010-03-31
Right now I'm going through the entire File from start finish and saving x rows into a Collection.

Is there any way to get the last x number of rows of a File with one method?

0
Comment
Question by:jerelw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 3

Accepted Solution

by:
shyamkumarreddy earned 200 total points
ID: 6914981
Yes Pls use Reader Object or derived of this class to ready the specific line.

Shyam
0
 
LVL 7

Expert Comment

by:Igor Bazarny
ID: 6915464
Check out http://follow.sourceforge.net/
it's tail implementation in java
0
 
LVL 3

Author Comment

by:jerelw
ID: 6916720
I'll check out the Reader Object.

...but will it work if I don't know the last line's number unless I open the File and read it line by line?
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 7

Expert Comment

by:Igor Bazarny
ID: 6917407
Check out RandomAccessFile then
0
 
LVL 3

Author Comment

by:jerelw
ID: 6918732
The Reader Object lets me skip characters, but I still have to go through the whole file.

Only now, because it's not a BufferedReader, I don't even know how many lines I've got unless I count newLines.

The Reader Object is not a solution.

...I'll check out the RandomAccessFile Object now.
0
 
LVL 3

Author Comment

by:jerelw
ID: 6918748
Ok,

Your answer was pretty vague, but I figured it out.

1. I got the size of the File
2. I skipped a set amount of (size - DEFAULT_TAIL_AMOUNT)
3. I then read the characters until I hit a new line
4. Finally, I send the remaining characters back to the screen.

Thank you
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month14 days, 2 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question