@Test public void testTailer() throws Exception { final long delayMillis = 50; final File file = new File(getTestDirectory(), "tailer1-test.txt"); createFile(file, 0); final TestTailerListener listener = new TestTailerListener(); final String osname = System.getProperty("os.name"); final boolean isWindows = osname.startsWith("Windows"); tailer = new Tailer(file, listener, delayMillis, false, isWindows); final Thread thread = new Thread(tailer); thread.start(); write(file, "Line one", "Line two"); final long testDelayMillis = delayMillis * 10; TestUtils.sleep(testDelayMillis); List<String> lines = listener.getLines(); assertEquals("1 line count", 2, lines.size()); assertEquals("1 line 1", "Line one", lines.get(0)); assertEquals("1 line 2", "Line two", lines.get(1)); listener.clear(); write(file, "Line three"); TestUtils.sleep(testDelayMillis); lines = listener.getLines(); assertEquals("2 line count", 1, lines.size()); assertEquals("2 line 3", "Line three", lines.get(0)); listener.clear(); lines = FileUtils.readLines(file, "UTF-8"); assertEquals("3 line count", 3, lines.size()); assertEquals("3 line 1", "Line one", lines.get(0)); assertEquals("3 line 2", "Line two", lines.get(1)); assertEquals("3 line 3", "Line three", lines.get(2)); file.delete(); final boolean exists = file.exists(); assertFalse("File should not exist", exists); createFile(file, 0); TestUtils.sleep(testDelayMillis); write(file, "Line four"); TestUtils.sleep(testDelayMillis); lines = listener.getLines(); assertEquals("4 line count", 1, lines.size()); assertEquals("4 line 3", "Line four", lines.get(0)); listener.clear(); thread.interrupt(); TestUtils.sleep(testDelayMillis * 4); write(file, "Line five"); assertEquals("4 line count", 0, listener.getLines().size()); assertNotNull("Missing InterruptedException", listener.exception); assertTrue("Unexpected Exception: " + listener.exception, listener.exception instanceof InterruptedException); assertEquals("Expected init to be called", 1 , listener.initialised); assertEquals("fileNotFound should not be called", 0 , listener.notFound); assertEquals("fileRotated should be be called", 1 , listener.rotated); tailer.stop(); tailer=null; }
public Tailer(final File file, final TailerListener listener) { this(file, listener, DEFAULT_DELAY_MILLIS); }
Tailer implements Runnable { public Tailer(final File file, final TailerListener listener) { this(file, listener, DEFAULT_DELAY_MILLIS); } }
Tailer implements Runnable { public Tailer(final File file, final TailerListener listener) { this(file, listener, DEFAULT_DELAY_MILLIS); } Tailer(final File file, final TailerListener listener);  Tailer(final File file, final TailerListener listener, final long delayMillis);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end,
                  final boolean reOpen);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end,
                  final int bufSize);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end,
                  final boolean reOpen, final int bufSize);  Tailer(final File file, final Charset cset, final TailerListener listener, final long delayMillis,
                  final boolean end, final boolean reOpen
            , final int bufSize); }
Tailer implements Runnable { public Tailer(final File file, final TailerListener listener) { this(file, listener, DEFAULT_DELAY_MILLIS); } Tailer(final File file, final TailerListener listener);  Tailer(final File file, final TailerListener listener, final long delayMillis);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end,
                  final boolean reOpen);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end,
                  final int bufSize);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end,
                  final boolean reOpen, final int bufSize);  Tailer(final File file, final Charset cset, final TailerListener listener, final long delayMillis,
                  final boolean end, final boolean reOpen
            , final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis,
                                final boolean end, final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis,
                                final boolean end, final boolean reOpen,
            final int bufSize); static Tailer create(final File file, final Charset charset, final TailerListener listener,
                                final long delayMillis, final boolean end, final boolean reOpen
            ,final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis,
                                final boolean end); static Tailer create(final File file, final TailerListener listener, final long delayMillis,
                                final boolean end, final boolean reOpen); static Tailer create(final File file, final TailerListener listener, final long delayMillis); static Tailer create(final File file, final TailerListener listener); File getFile(); long getDelay(); void run(); void stop(); }
Tailer implements Runnable { public Tailer(final File file, final TailerListener listener) { this(file, listener, DEFAULT_DELAY_MILLIS); } Tailer(final File file, final TailerListener listener);  Tailer(final File file, final TailerListener listener, final long delayMillis);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end,
                  final boolean reOpen);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end,
                  final int bufSize);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end,
                  final boolean reOpen, final int bufSize);  Tailer(final File file, final Charset cset, final TailerListener listener, final long delayMillis,
                  final boolean end, final boolean reOpen
            , final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis,
                                final boolean end, final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis,
                                final boolean end, final boolean reOpen,
            final int bufSize); static Tailer create(final File file, final Charset charset, final TailerListener listener,
                                final long delayMillis, final boolean end, final boolean reOpen
            ,final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis,
                                final boolean end); static Tailer create(final File file, final TailerListener listener, final long delayMillis,
                                final boolean end, final boolean reOpen); static Tailer create(final File file, final TailerListener listener, final long delayMillis); static Tailer create(final File file, final TailerListener listener); File getFile(); long getDelay(); void run(); void stop();  }