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:
@@ -3,10 +3,11 @@
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# 5.7.18 (2021-12-09)
|
# 5.7.18 (2021-12-12)
|
||||||
|
|
||||||
### 🐣新特性
|
### 🐣新特性
|
||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
|
* 【core 】 LineReadWatcher#onModify文件清空判断问题(issue#2013@Github)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
# 5.7.17 (2021-12-09)
|
# 5.7.17 (2021-12-09)
|
||||||
|
@@ -50,11 +50,11 @@ public class LineReadWatcher extends SimpleWatcher implements Runnable {
|
|||||||
try {
|
try {
|
||||||
final long currentLength = randomAccessFile.length();
|
final long currentLength = randomAccessFile.length();
|
||||||
final long position = randomAccessFile.getFilePointer();
|
final long position = randomAccessFile.getFilePointer();
|
||||||
if (0 == currentLength || position == currentLength) {
|
if (position == currentLength) {
|
||||||
// 内容长度不变时忽略此次事件
|
// 内容长度不变时忽略此次事件
|
||||||
return;
|
return;
|
||||||
} else if (currentLength < position) {
|
} else if (currentLength < position) {
|
||||||
// 如果内容变短,说明文件做了删改,回到内容末尾
|
// 如果内容变短或变0,说明文件做了删改或清空,回到内容末尾或0
|
||||||
randomAccessFile.seek(currentLength);
|
randomAccessFile.seek(currentLength);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -7,13 +7,13 @@ import cn.hutool.core.io.FileUtil;
|
|||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
|
|
||||||
public class TailerTest {
|
public class TailerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
public void tailTest() {
|
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
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
public void tailWithLinesTest() {
|
public void tailWithLinesTest() {
|
||||||
|
Reference in New Issue
Block a user