It is best to use the Process class and read using Scanner :
Runtime r = Runtime.getRuntime() Process p = r.exec("tail -f") Scanner s = new Scanner(p.getInputStream()) while (s.hasNextLine()) { String line = s.nextLine()
hasNextLine() should be blocked, as it expects more input from the input stream, so you will not be busy reviving as the data arrives.
source share