/** * Creates and starts a Tailer for the given file, starting at the beginning of the file * * @param file the file to follow. * @param listener the TailerListener to use. * @param delayMillis the delay between checks of the file for new content in milliseconds. * @return The new tailer */ public static Tailer create(final File file, final TailerListener listener, final long delayMillis) { return create(file, listener, delayMillis, false); }
/** * Creates and starts a Tailer for the given file, starting at the beginning of the file * with the default delay of 1.0s * * @param file the file to follow. * @param listener the TailerListener to use. * @return The new tailer */ public static Tailer create(final File file, final TailerListener listener) { return create(file, listener, DEFAULT_DELAY_MILLIS, false); }
/** * Creates and starts a Tailer for the given file with default buffer size. * * @param file the file to follow. * @param listener the TailerListener to use. * @param delayMillis the delay between checks of the file for new content in milliseconds. * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. * @return The new tailer */ public static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end) { return create(file, listener, delayMillis, end, DEFAULT_BUFSIZE); }
/** * Creates and starts a Tailer for the given file with default buffer size. * * @param file the file to follow. * @param listener the TailerListener to use. * @param delayMillis the delay between checks of the file for new content in milliseconds. * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. * @param reOpen whether to close/reopen the file between chunks * @return The new tailer */ public static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen) { return create(file, listener, delayMillis, end, reOpen, DEFAULT_BUFSIZE); }
/** * Creates and starts a Tailer for the given file. * * @param file the file to follow. * @param listener the TailerListener to use. * @param delayMillis the delay between checks of the file for new content in milliseconds. * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. * @param bufSize buffer size. * @return The new tailer */ public static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final int bufSize) { return create(file, listener, delayMillis, end, false, bufSize); }
/** * Creates and starts a Tailer for the given file. * * @param file the file to follow. * @param listener the TailerListener to use. * @param delayMillis the delay between checks of the file for new content in milliseconds. * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. * @param reOpen whether to close/reopen the file between chunks * @param bufSize buffer size. * @return The new tailer */ public static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end, final boolean reOpen, final int bufSize) { return create(file, DEFAULT_CHARSET, listener, delayMillis, end, reOpen, bufSize); }
@Test public void testStopWithNoFile() throws Exception { final File file = new File(getTestDirectory(),"nosuchfile"); assertFalse("nosuchfile should not exist", file.exists()); final TestTailerListener listener = new TestTailerListener(); final int delay = 100; final int idle = 50; // allow time for thread to work tailer = Tailer.create(file, listener, delay, false); TestUtils.sleep(idle); tailer.stop(); TestUtils.sleep(delay+idle); assertNull("Should not generate Exception", listener.exception); assertEquals("Expected init to be called", 1 , listener.initialised); assertTrue("fileNotFound should be called", listener.notFound > 0); assertEquals("fileRotated should be not be called", 0 , listener.rotated); assertEquals("end of file never reached", 0, listener.reachedEndOfFile); }
/** * Creates and starts a Tailer for the given file, starting at the beginning of the file * with the default delay of 1.0s * * @param file the file to follow. * @param listener the TailerListener to use. * @return The new tailer */ public static Tailer create(File file, TailerListener listener) { return create(file, listener, DEFAULT_DELAY_MILLIS, false); }
/** * Creates and starts a Tailer for the given file, starting at the beginning of the file * * @param file the file to follow. * @param listener the TailerListener to use. * @param delayMillis the delay between checks of the file for new content in milliseconds. * @return The new tailer */ public static Tailer create(final File file, final TailerListener listener, final long delayMillis) { return create(file, listener, delayMillis, false); }
/** * Creates and starts a Tailer for the given file, starting at the beginning of the file * with the default delay of 1.0s * * @param file the file to follow. * @param listener the TailerListener to use. * @return The new tailer */ public static Tailer create(final File file, final TailerListener listener) { return create(file, listener, DEFAULT_DELAY_MILLIS, false); }
/** * Creates and starts a Tailer for the given file, starting at the beginning of the file * * @param file the file to follow. * @param listener the TailerListener to use. * @param delay the delay between checks of the file for new content in milliseconds. * @return The new tailer */ public static Tailer create(File file, TailerListener listener, long delay) { return create(file, listener, delay, false); }
/** * Creates and starts a Tailer for the given file, starting at the beginning of the file * with the default delay of 1.0s * * @param file the file to follow. * @param listener the TailerListener to use. * @return The new tailer */ public static Tailer create(File file, TailerListener listener) { return create(file, listener, 1000, false); }
/** * Creates and starts a Tailer for the given file with default buffer size. * * @param file the file to follow. * @param listener the TailerListener to use. * @param delayMillis the delay between checks of the file for new content in milliseconds. * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. * @param reOpen whether to close/reopen the file between chunks * @return The new tailer */ public static Tailer create(File file, TailerListener listener, long delayMillis, boolean end, boolean reOpen) { return create(file, listener, delayMillis, end, reOpen, DEFAULT_BUFSIZE); }
/** * Creates and starts a Tailer for the given file with default buffer size. * * @param file the file to follow. * @param listener the TailerListener to use. * @param delayMillis the delay between checks of the file for new content in milliseconds. * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. * @return The new tailer */ public static Tailer create(final File file, final TailerListener listener, final long delayMillis, final boolean end) { return create(file, listener, delayMillis, end, DEFAULT_BUFSIZE); }
/** * Creates and starts a Tailer for the given file with default buffer size. * * @param file the file to follow. * @param listener the TailerListener to use. * @param delayMillis the delay between checks of the file for new content in milliseconds. * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. * @return The new tailer */ public static Tailer create(File file, TailerListener listener, long delayMillis, boolean end) { return create(file, listener, delayMillis, end, DEFAULT_BUFSIZE); }
/** * Creates and starts a Tailer for the given file, starting at the beginning of the file * * @param file the file to follow. * @param listener the TailerListener to use. * @param delayMillis the delay between checks of the file for new content in milliseconds. * @return The new tailer */ public static Tailer create(File file, TailerListener listener, long delayMillis) { return create(file, listener, delayMillis, false); }
/** * Creates and starts a Tailer for the given file, starting at the beginning of the file * with the default delay of 1.0s * * @param file the file to follow. * @param listener the TailerListener to use. * @return The new tailer */ public static Tailer create(final File file, final TailerListener listener) { return create(file, listener, DEFAULT_DELAY_MILLIS, false); }
@Override protected void onFirstClientConnect() { tailer = Tailer.create(new File(settings.get(SETTINGS_PATH)), this, 1000, true); tailerRunning = true; }
private void addTailers(Iterable<TailerListener> tailerListeners, File file, ListenableFuture<?> future) { Executor directExecutor = MoreExecutors.directExecutor(); for (TailerListener tailerListener : tailerListeners) { Tailer tailer = org.apache.commons.io.input.Tailer.create(file, tailerListener); Futures.addCallback(future, new TailerStopper(tailer), directExecutor); } }
@Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.textview, container, false); mTextArea = (TextView) v.findViewById(R.id.textview); File logFile = new File(getActivity().getFilesDir(), getString(R.string.path_mainlog)); mTailer = Tailer.create(logFile, this, 400, true); return v; }