public class FileReader extends FileWrapper
| Modifier and Type | Class and Description |
|---|---|
static interface |
FileReader.ReaderHandler<T>
Reader处理接口
|
charset, DEFAULT_CHARSET, file| Constructor and Description |
|---|
FileReader(File file)
构造
编码使用
FileWrapper.DEFAULT_CHARSET |
FileReader(File file,
Charset charset)
构造
|
FileReader(File file,
String charset)
构造
|
FileReader(String filePath)
构造
编码使用
FileWrapper.DEFAULT_CHARSET |
FileReader(String filePath,
Charset charset)
构造
|
FileReader(String filePath,
String charset)
构造
|
| Modifier and Type | Method and Description |
|---|---|
static FileReader |
create(File file)
创建 FileReader, 编码:
FileWrapper.DEFAULT_CHARSET |
static FileReader |
create(File file,
Charset charset)
创建 FileReader
|
BufferedInputStream |
getInputStream()
获得输入流
|
BufferedReader |
getReader()
获得一个文件读取器
|
<T> T |
read(FileReader.ReaderHandler<T> readerHandler)
按照给定的readerHandler读取文件中的数据
|
byte[] |
readBytes()
读取文件所有数据
文件的长度不能超过
Integer.MAX_VALUE |
List<String> |
readLines()
从文件中读取每一行数据
|
void |
readLines(LineHandler lineHandler)
按照行处理文件内容
|
<T extends Collection<String>> |
readLines(T collection)
从文件中读取每一行数据
|
String |
readString()
读取文件内容
|
File |
writeToStream(OutputStream out)
将文件写入流中
|
getCharset, getFile, readableFileSize, setCharset, setFilepublic FileReader(String filePath, Charset charset)
filePath - 文件路径,相对路径会被转换为相对于ClassPath的路径charset - 编码public FileReader(String filePath, String charset)
filePath - 文件路径,相对路径会被转换为相对于ClassPath的路径charset - 编码public FileReader(File file)
FileWrapper.DEFAULT_CHARSETfile - 文件public FileReader(String filePath)
FileWrapper.DEFAULT_CHARSETfilePath - 文件路径,相对路径会被转换为相对于ClassPath的路径public static FileReader create(File file, Charset charset)
file - 文件charset - 编码FileReaderpublic static FileReader create(File file)
FileWrapper.DEFAULT_CHARSETfile - 文件FileReaderpublic byte[] readBytes()
throws InstrumentException
Integer.MAX_VALUEInstrumentException - 异常public String readString() throws InstrumentException
InstrumentException - 异常public <T extends Collection<String>> T readLines(T collection) throws InstrumentException
T - 集合类型collection - 集合InstrumentException - 异常public void readLines(LineHandler lineHandler) throws InstrumentException
lineHandler - 行处理器InstrumentException - 异常public List<String> readLines() throws InstrumentException
InstrumentException - 异常public <T> T read(FileReader.ReaderHandler<T> readerHandler) throws InstrumentException
T - 读取的结果对象类型readerHandler - Reader处理类InstrumentException - 异常public BufferedReader getReader() throws InstrumentException
InstrumentException - 异常public BufferedInputStream getInputStream() throws InstrumentException
InstrumentException - 异常public File writeToStream(OutputStream out) throws InstrumentException
out - 流InstrumentException - 异常Copyright © 2019. All rights reserved.