Package org.miaixz.bus.core.io.file
Class FileReader
java.lang.Object
org.miaixz.bus.core.io.file.FileWrapper
org.miaixz.bus.core.io.file.FileReader
- All Implemented Interfaces:
Serializable,Wrapper<File>
文件读取器
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
Fields inherited from class org.miaixz.bus.core.io.file.FileWrapper
charset, DEFAULT_CHARSET, file -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription获得输入流获得一个文件读取器static FileReader创建 FileReader, 编码:FileWrapper.DEFAULT_CHARSETstatic FileReader创建 FileReader<T> Tread(FunctionX<BufferedReader, T> readerHandler) 按照给定的readerHandler读取文件中的数据byte[]读取文件所有数据 文件的长度不能超过Integer.MAX_VALUE从文件中读取每一行数据void按照行处理文件内容<T extends Collection<String>>
TreadLines(T collection) 从文件中读取每一行数据<T extends Collection<String>>
T从文件中读取每一行数据读取文件内容long将文件写入流中,此方法不会关闭比输出流longwriteToStream(OutputStream out, boolean isCloseOut) 将文件写入流中Methods inherited from class org.miaixz.bus.core.io.file.FileWrapper
getCharset, getRaw, readableFileSize, setCharset, setFile
-
Constructor Details
-
FileReader
构造- Parameters:
file- 文件charset- 编码,使用Charset
-
-
Method Details
-
of
创建 FileReader- Parameters:
file- 文件charset- 编码,使用Charset- Returns:
- FileReader
-
of
创建 FileReader, 编码:FileWrapper.DEFAULT_CHARSET- Parameters:
file- 文件- Returns:
- FileReader
-
readBytes
读取文件所有数据 文件的长度不能超过Integer.MAX_VALUE- Returns:
- 字节码
- Throws:
InternalException- IO异常
-
readString
读取文件内容- Returns:
- 内容
- Throws:
InternalException- IO异常
-
readLines
从文件中读取每一行数据- Type Parameters:
T- 集合类型- Parameters:
collection- 集合- Returns:
- 文件中的每行内容的集合
- Throws:
InternalException- IO异常
-
readLines
public <T extends Collection<String>> T readLines(T collection, Predicate<String> predicate) throws InternalException 从文件中读取每一行数据- Type Parameters:
T- 集合类型- Parameters:
collection- 集合predicate- 断言,断言为真的加入到提供的集合中- Returns:
- 文件中的每行内容的集合
- Throws:
InternalException- IO异常
-
readLines
按照行处理文件内容- Parameters:
lineHandler- 行处理器- Throws:
InternalException- IO异常
-
readLines
从文件中读取每一行数据- Returns:
- 文件中的每行内容的集合
- Throws:
InternalException- IO异常
-
read
按照给定的readerHandler读取文件中的数据- Type Parameters:
T- 读取的结果对象类型- Parameters:
readerHandler- Reader处理类- Returns:
- 从文件中read出的数据
- Throws:
InternalException- IO异常
-
getReader
获得一个文件读取器- Returns:
- BufferedReader对象
- Throws:
InternalException- IO异常
-
getInputStream
获得输入流- Returns:
- 输入流
- Throws:
InternalException- IO异常
-
writeToStream
将文件写入流中,此方法不会关闭比输出流- Parameters:
out- 流- Returns:
- 写出的流byte数
- Throws:
InternalException- IO异常
-
writeToStream
将文件写入流中- Parameters:
out- 流isCloseOut- 是否关闭输出流- Returns:
- 写出的流byte数
- Throws:
InternalException- IO异常
-