Read a file while it's being written

前端 未结 2 1399
我在风中等你
我在风中等你 2021-01-25 05:55

I have to read the tomcat log file,and after some time(for example:one hour) I will read the file again(just for the new added content),so I create the RandomAccessFile to recor

2条回答
  •  别那么骄傲
    2021-01-25 06:19

    readLine consumes the newline character. You can't use it to determine if you have a complete line or not. You need to read one byte at a time and parse the line yourself.

    Also you are not moving on the position when you get a valid line..

提交回复
热议问题