From 13175399f6bebc071ebacde20fe2349b5f0630b8 Mon Sep 17 00:00:00 2001 From: Stefan Begerad Date: Tue, 30 Nov 2021 10:05:19 -0500 Subject: [PATCH] feat(tailer): added parameter to Tailer call --- .../src/main/java/de/swingbe/tailer/Main.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tailer/src/main/java/de/swingbe/tailer/Main.java b/tailer/src/main/java/de/swingbe/tailer/Main.java index 28fcabb..4fced6e 100644 --- a/tailer/src/main/java/de/swingbe/tailer/Main.java +++ b/tailer/src/main/java/de/swingbe/tailer/Main.java @@ -7,13 +7,30 @@ import java.io.File; public class Main { + //delay between checks of the file for new content in milliseconds + public static final int DELAY_MILLIS = 500; + + //set to true to tail from the end of the file, false to tail from the beginning of the file + public static final boolean END = true; + public static void main(String[] args) { System.out.println("Hello world!"); TailerListener listener = new MyListener(); - Tailer tailer = new Tailer(new File("NetPeerManager.log"), listener, 500); + + //create and use a Tailer with a Thread + String fileName = "NetPeerManager.log"; + //TODO What is the behaviour of the reOpen parameter? + Tailer tailer = new Tailer(new File(fileName), listener, DELAY_MILLIS, END); tailer.run(); + Thread thread = new Thread(tailer); + + //optional + thread.setDaemon(true); + + thread.start(); + return; } }