mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix line bug
This commit is contained in:
@@ -50,11 +50,11 @@ public class LineReadWatcher extends SimpleWatcher implements Runnable {
|
||||
try {
|
||||
final long currentLength = randomAccessFile.length();
|
||||
final long position = randomAccessFile.getFilePointer();
|
||||
if (0 == currentLength || position == currentLength) {
|
||||
if (position == currentLength) {
|
||||
// 内容长度不变时忽略此次事件
|
||||
return;
|
||||
} else if (currentLength < position) {
|
||||
// 如果内容变短,说明文件做了删改,回到内容末尾
|
||||
// 如果内容变短或变0,说明文件做了删改或清空,回到内容末尾或0
|
||||
randomAccessFile.seek(currentLength);
|
||||
return;
|
||||
}
|
||||
|
@@ -7,13 +7,13 @@ import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
|
||||
public class TailerTest {
|
||||
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void tailTest() {
|
||||
FileUtil.tail(FileUtil.file("e:/tail.txt"), CharsetUtil.CHARSET_GBK);
|
||||
FileUtil.tail(FileUtil.file("d:/test/tail.txt"), CharsetUtil.CHARSET_GBK);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void tailWithLinesTest() {
|
||||
|
Reference in New Issue
Block a user