public class FileSearchUtil extends Object
Constructor and Description |
---|
FileSearchUtil() |
Modifier and Type | Method and Description |
---|---|
static int[] |
calculate(int head,
int tailLine,
boolean first)
计算读取文件行数相关
|
static Collection<cn.hutool.core.lang.Tuple> |
readLastLine(File file,
Charset charset,
int line) |
static Collection<cn.hutool.core.lang.Tuple> |
readRangeLine(File file,
Charset charset,
int[] range) |
static String |
searchList(File file,
Charset charset,
String searchKey,
int cacheBeforeCount,
int afterCount,
int head,
int tailCount,
boolean first,
Consumer<cn.hutool.core.lang.Tuple> consumer) |
public static String searchList(File file, Charset charset, String searchKey, int cacheBeforeCount, int afterCount, int head, int tailCount, boolean first, Consumer<cn.hutool.core.lang.Tuple> consumer) throws IOException
file
- 文件charset
- 编码格式searchKey
- 搜索关键词cacheBeforeCount
- 关键词前多少行afterCount
- 关键词后多少行head
- 搜索文件头多少行tailCount
- 文件后多少行first
- 是否从头开始读取consumer
- 回调IOException
- iopublic static Collection<cn.hutool.core.lang.Tuple> readLastLine(File file, Charset charset, int line) throws IOException
IOException
public static Collection<cn.hutool.core.lang.Tuple> readRangeLine(File file, Charset charset, int[] range) throws IOException
IOException
public static int[] calculate(int head, int tailLine, boolean first)
head
- 从文件头开始读取tailLine
- 读最后几乎first
- 是否从头开始读取Copyright © 2017–2022. All rights reserved.