commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niall Pemberton <niall.pember...@gmail.com>
Subject Re: [IO] tailer sample code
Date Wed, 10 Nov 2010 23:42:54 GMT
2010/11/10 Sébastien Roux <roux.sebastien@gmail.com>:
> I'm not a Java specialist but quite curious about the new tailer classes in
> commons IO 2.0.
>
> Now what does this mean : TailerListener listener = ...

Its just an abbreviation to show the line is not complete.

You have to create your own TailerListener implementation which does
whatever you want with the lines added to the file. So for example you
could do something like the following:

    /**
     * TailerListener implementation.
     */
    public class ShowLinesListener extends TailerListenerAdapter {
        @Override
        public void handle(String line) {
            System.out.println(line);
        }
    }

Then create the Tailer with your implementation:

    TailerListener listener = new ShowLinesListener();
    Tailer tailer = Tailer.create(file, listener, delay);

http://commons.apache.org/io/api-release/org/apache/commons/io/input/Tailer.html

Niall

> I mean what I am supposed to put after the equal? Would you have a quick
> example regarding basic file tailing implementation?
>
> I also checked this without getting the picture =>
> http://permalink.gmane.org/gmane.comp.jakarta.commons.scm/9636
>
> Many thanks for any guidance you may provide.
>
> Sébastien Roux
> mail:  roux.sebastien@gmail.com
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message