[ 
https://issues.apache.org/jira/browse/IO-450?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14556021#comment-14556021
 ] 

Benedikt Ritter commented on IO-450:
------------------------------------

The problem is, that tail is stream based but Tailer is line based. So the 
comparison doesn't work out completely. If I have a file with the following 
content:

{code}
AAAAAAA\n
BBBBBBB
{code}

And I do a {{tail -f}} on the file, I'll get the following output:

{code}
$: tail -f file.txt
AAAAAAA
BBBBBBB
{code}

It simply waits for new input on the last line. That could be an EOL or it 
could be EOF. Tailer OTOH currently detects lines based on the EOL character. I 
agree that lines without EOF at EOF should also be handled. A simple solution 
would be to call {{listener.handle(new String(lineBuf.toByteArray(), cset))}} 
after the while-loop in {{readLines(final RandomAccessFile reader)}} if the 
{{lineBuf}} stil has content.

> File doesn't end with blank line and cann't get the last line using Tailer!
> ---------------------------------------------------------------------------
>
>                 Key: IO-450
>                 URL: https://issues.apache.org/jira/browse/IO-450
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 2.4
>         Environment: linux and windows 7
>            Reporter: davidchiu
>            Priority: Minor
>             Fix For: 2.5
>
>
> I use Tailer to read file, I can't get the last line if the file doesn't end 
> with a blank line!
> My file like as following:
> AAAAAAAAAAAA
> BBBBBBBBBBBB
> And Not end with a blank line, "BBBBBBBBBBBB" is the last line, When I use 
> io.input.Tailer to tail the file, I cann't get the last line "BBBBBBBBBBBB"!
> All  versions(2.3/2.4/2.5) of Commons-IO have the same problem! 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to