Reputation: 169
I'm giving a tail -f command on a log file through java. When a certain string is found, I want to stop following the file and execute the rest of my code. How do I stop it using Java?
Thanks
Upvotes: 0
Views: 296
Reputation: 30088
I know that this isn't a direct answer to your question, but using a native shell command probably isn't the best way to do this. In addition to the problem that you are experiencing, it makes the code non-portable.
Have a look at Apache's 'Tailer' class - see http://commons.apache.org/io/api-release/org/apache/commons/io/input/Tailer.html It has a stop() method.
Upvotes: 2