I want to tail file contents using Java.I tried using Tailer and TailerListenerAdapter of Apache commons io. I have included storm-core-1.1.1.jar in the classpath for the required dependencies.Program compiles and runs; But the 'handle' method of TailerListenerAdapter is not called at all and the execution gets stuck inside the main method.Following is the code:
import org.apache.storm.shade.org.apache.commons.io.input.TailerListenerAdapter;
import org.apache.storm.shade.org.apache.commons.io.input.Tailer;
import org.apache.storm.shade.org.apache.commons.io.input.TailerListener;
import java.io.File;
public class LogTailTest {
/**
* TailerListener implementation.
*/
static public class ShowLinesListener extends TailerListenerAdapter {
@Override
public void handle(String line) {
System.out.println(line);
System.out.println("inside handle");
}
}
public static void main(String args[]) {
TailerListener listener = new ShowLinesListener();
File file = new File("C:/LogFiles/Radius-log");
System.out.println("inside main");
Tailer tailer = Tailer.create(file, listener);
tailer.run();
}
}