[update]FileUtil优化分页读取

This commit is contained in:
yexuejc 2023-07-19 20:14:15 +08:00
parent 667ad26971
commit c4fc4bd4f8
2 changed files with 5 additions and 1 deletions

View File

@ -120,4 +120,8 @@ public class ReadFileBean<T> {
public String lineScavenge(String lineData) {
return this.lineScavenger.apply(lineData);
}
public boolean hasNext() {
return this.fileLength > this.pointer;
}
}

View File

@ -504,7 +504,7 @@ public class FileUtil {
List<String> datas = new ArrayList<>();
int row = 1;
String line;
while ((line = randomAccessFile.readLine()) != null && row < readFileBean.getReadRowNum()) {
while ((line = randomAccessFile.readLine()) != null && row <= readFileBean.getReadRowNum()) {
row++;
readFileBean.setPointer(randomAccessFile.getFilePointer());
datas.add(readFileBean.lineScavenge(charsetDecode(line, readFileBean.getReadCharset()))); }