Tailing a file in Clojure?

后端 未结 3 1865
独厮守ぢ
独厮守ぢ 2021-02-03 11:09

What would be the best method to tail a file in Clojure? I haven\'t come across any utilities that would help do so, but ideas on how to build one would be appreciated!

3条回答
  •  闹比i
    闹比i (楼主)
    2021-02-03 11:34

    You can use RandomAccessFile to seek directly to the end of the file and search for linebreaks from there. Not as elegant and short as the take-last approach, but also not O(n) which might matter for big file sizes.

    No solution for tail -f, though. Some inspiration might be found in JLogTailer.

提交回复
热议问题