程序包 dev.utils.common
类 FileIOUtils
java.lang.Object
dev.utils.common.FileIOUtils
detail: 文件 ( IO 流 ) 工具类
- 作者:
- Ttt
-
字段概要
字段 -
方法概要
修饰符和类型方法说明static longcopyLarge(InputStream inputStream, OutputStream outputStream) 复制 InputStream 到 OutputStreamstatic FileInputStreamgetFileInputStream(File file) 获取输入流static FileInputStreamgetFileInputStream(String filePath) 获取输入流static FileOutputStreamgetFileOutputStream(File file) 获取输出流static FileOutputStreamgetFileOutputStream(File file, boolean append) 获取输出流static FileOutputStreamgetFileOutputStream(String filePath) 获取输出流static FileOutputStreamgetFileOutputStream(String filePath, boolean append) 获取输出流static byte[]readFileToBytesByChannel(File file) 通过 FileChannel, 读取文件内容, 返回 byte[]static byte[]readFileToBytesByChannel(String filePath) 通过 FileChannel, 读取文件内容, 返回 byte[]static byte[]readFileToBytesByMap(File file) 通过 MappedByteBuffer, 读取文件内容, 返回 byte[]static byte[]readFileToBytesByMap(String filePath) 通过 MappedByteBuffer, 读取文件内容, 返回 byte[]static byte[]readFileToBytesByStream(File file) 读取文件内容, 返回 byte[]static byte[]readFileToBytesByStream(String filePath) 读取文件内容, 返回 byte[]readFileToList(File file) 读取文件内容, 返回换行 ListreadFileToList(File file, int start, int end) 读取文件内容, 返回换行 ListreadFileToList(File file, int start, int end, String charsetName) 读取文件内容, 返回换行 ListreadFileToList(File file, String charsetName) 读取文件内容, 返回换行 ListreadFileToList(String filePath) 读取文件内容, 返回换行 ListreadFileToList(String filePath, int start, int end) 读取文件内容, 返回换行 ListreadFileToList(String filePath, int start, int end, String charsetName) 读取文件内容, 返回换行 ListreadFileToList(String filePath, String charsetName) 读取文件内容, 返回换行 Liststatic StringreadFileToString(File file) 读取文件内容, 返回字符串static StringreadFileToString(File file, String charsetName) 读取文件内容, 返回字符串static StringreadFileToString(String filePath) 读取文件内容, 返回字符串static StringreadFileToString(String filePath, String charsetName) 读取文件内容, 返回字符串static voidsetBufferSize(int bufferSize) 设置缓冲区的大小, 默认大小等于 8192 字节static booleanwriteFileFromBytesByChannel(File file, byte[] bytes, boolean isForce) 通过 FileChannel 把字节流写入文件static booleanwriteFileFromBytesByChannel(File file, byte[] bytes, boolean append, boolean isForce) 通过 FileChannel 把字节流写入文件static booleanwriteFileFromBytesByChannel(String filePath, byte[] bytes, boolean isForce) 通过 FileChannel 把字节流写入文件static booleanwriteFileFromBytesByChannel(String filePath, byte[] bytes, boolean append, boolean isForce) 通过 FileChannel 把字节流写入文件static booleanwriteFileFromBytesByMap(File file, byte[] bytes, boolean isForce) 通过 MappedByteBuffer 把字节流写入文件static booleanwriteFileFromBytesByMap(File file, byte[] bytes, boolean append, boolean isForce) 通过 MappedByteBuffer 把字节流写入文件static booleanwriteFileFromBytesByMap(String filePath, byte[] bytes, boolean isForce) 通过 MappedByteBuffer 把字节流写入文件static booleanwriteFileFromBytesByMap(String filePath, byte[] bytes, boolean append, boolean isForce) 通过 MappedByteBuffer 把字节流写入文件static booleanwriteFileFromBytesByStream(File file, byte[] bytes) 通过字节流写入文件static booleanwriteFileFromBytesByStream(File file, byte[] bytes, boolean append) 通过字节流写入文件static booleanwriteFileFromBytesByStream(String filePath, byte[] bytes) 通过字节流写入文件static booleanwriteFileFromBytesByStream(String filePath, byte[] bytes, boolean append) 通过字节流写入文件static booleanwriteFileFromIS(File file, InputStream inputStream) 通过输入流写入文件static booleanwriteFileFromIS(File file, InputStream inputStream, boolean append) 通过输入流写入文件static booleanwriteFileFromIS(String filePath, InputStream inputStream) 通过输入流写入文件static booleanwriteFileFromIS(String filePath, InputStream inputStream, boolean append) 通过输入流写入文件static booleanwriteFileFromString(File file, String content) 通过字符串写入文件static booleanwriteFileFromString(File file, String content, boolean append) 通过字符串写入文件static booleanwriteFileFromString(String filePath, String content) 通过字符串写入文件static booleanwriteFileFromString(String filePath, String content, boolean append) 通过字符串写入文件
-
字段详细资料
-
EOF
public static final int EOF- 另请参阅:
-
-
方法详细资料
-
setBufferSize
public static void setBufferSize(int bufferSize) 设置缓冲区的大小, 默认大小等于 8192 字节- 参数:
bufferSize- 缓冲 Buffer 大小
-
getFileInputStream
获取输入流- 参数:
filePath- 文件路径- 返回:
FileInputStream
-
getFileInputStream
获取输入流- 参数:
file- 文件- 返回:
FileInputStream
-
getFileOutputStream
获取输出流- 参数:
filePath- 文件路径- 返回:
FileOutputStream
-
getFileOutputStream
获取输出流- 参数:
filePath- 文件路径append- 是否追加到结尾- 返回:
FileOutputStream
-
getFileOutputStream
获取输出流- 参数:
file- 文件- 返回:
FileOutputStream
-
getFileOutputStream
获取输出流- 参数:
file- 文件append- 是否追加到结尾- 返回:
FileOutputStream
-
writeFileFromIS
通过输入流写入文件- 参数:
filePath- 文件路径inputStream-InputStream- 返回:
truesuccess,falsefail
-
writeFileFromIS
通过输入流写入文件- 参数:
filePath- 文件路径inputStream-InputStreamappend- 是否追加到结尾- 返回:
truesuccess,falsefail
-
writeFileFromIS
通过输入流写入文件- 参数:
file- 文件inputStream-InputStream- 返回:
truesuccess,falsefail
-
writeFileFromIS
通过输入流写入文件- 参数:
file- 文件inputStream-InputStreamappend- 是否追加到结尾- 返回:
truesuccess,falsefail
-
writeFileFromBytesByStream
通过字节流写入文件- 参数:
filePath- 文件路径bytes- byte[]- 返回:
truesuccess,falsefail
-
writeFileFromBytesByStream
通过字节流写入文件- 参数:
filePath- 文件路径bytes- byte[]append- 是否追加到结尾- 返回:
truesuccess,falsefail
-
writeFileFromBytesByStream
通过字节流写入文件- 参数:
file- 文件bytes- byte[]- 返回:
truesuccess,falsefail
-
writeFileFromBytesByStream
通过字节流写入文件- 参数:
file- 文件bytes- byte[]append- 是否追加到结尾- 返回:
truesuccess,falsefail
-
writeFileFromBytesByChannel
通过 FileChannel 把字节流写入文件- 参数:
filePath- 文件路径bytes- byte[]isForce- 是否强制写入- 返回:
truesuccess,falsefail
-
writeFileFromBytesByChannel
public static boolean writeFileFromBytesByChannel(String filePath, byte[] bytes, boolean append, boolean isForce) 通过 FileChannel 把字节流写入文件- 参数:
filePath- 文件路径bytes- byte[]append- 是否追加到结尾isForce- 是否强制写入- 返回:
truesuccess,falsefail
-
writeFileFromBytesByChannel
通过 FileChannel 把字节流写入文件- 参数:
file- 文件bytes- byte[]isForce- 是否强制写入- 返回:
truesuccess,falsefail
-
writeFileFromBytesByChannel
public static boolean writeFileFromBytesByChannel(File file, byte[] bytes, boolean append, boolean isForce) 通过 FileChannel 把字节流写入文件- 参数:
file- 文件bytes- byte[]append- 是否追加到结尾isForce- 是否强制写入- 返回:
truesuccess,falsefail
-
writeFileFromBytesByMap
通过 MappedByteBuffer 把字节流写入文件- 参数:
filePath- 文件路径bytes- byte[]isForce- 是否强制写入- 返回:
truesuccess,falsefail
-
writeFileFromBytesByMap
public static boolean writeFileFromBytesByMap(String filePath, byte[] bytes, boolean append, boolean isForce) 通过 MappedByteBuffer 把字节流写入文件- 参数:
filePath- 文件路径bytes- byte[]append- 是否追加到结尾isForce- 是否强制写入- 返回:
truesuccess,falsefail
-
writeFileFromBytesByMap
通过 MappedByteBuffer 把字节流写入文件- 参数:
file- 文件bytes- byte[]isForce- 是否强制写入- 返回:
truesuccess,falsefail
-
writeFileFromBytesByMap
public static boolean writeFileFromBytesByMap(File file, byte[] bytes, boolean append, boolean isForce) 通过 MappedByteBuffer 把字节流写入文件- 参数:
file- 文件bytes- byte[]append- 是否追加到结尾isForce- 是否强制写入- 返回:
truesuccess,falsefail
-
writeFileFromString
通过字符串写入文件- 参数:
filePath- 文件路径content- 写入内容- 返回:
truesuccess,falsefail
-
writeFileFromString
通过字符串写入文件- 参数:
filePath- 文件路径content- 写入内容append- 是否追加到结尾- 返回:
truesuccess,falsefail
-
writeFileFromString
通过字符串写入文件- 参数:
file- 文件content- 写入内容- 返回:
truesuccess,falsefail
-
writeFileFromString
通过字符串写入文件- 参数:
file- 文件content- 写入内容append- 是否追加到结尾- 返回:
truesuccess,falsefail
-
readFileToList
读取文件内容, 返回换行 List -
readFileToList
读取文件内容, 返回换行 List -
readFileToList
读取文件内容, 返回换行 List -
readFileToList
读取文件内容, 返回换行 List -
readFileToList
读取文件内容, 返回换行 List -
readFileToList
读取文件内容, 返回换行 List -
readFileToList
读取文件内容, 返回换行 List -
readFileToList
读取文件内容, 返回换行 List -
readFileToString
读取文件内容, 返回字符串- 参数:
filePath- 文件路径- 返回:
- 文件内容字符串
-
readFileToString
读取文件内容, 返回字符串- 参数:
filePath- 文件路径charsetName- 字符编码- 返回:
- 文件内容字符串
-
readFileToString
读取文件内容, 返回字符串- 参数:
file- 文件- 返回:
- 文件内容字符串
-
readFileToString
读取文件内容, 返回字符串- 参数:
file- 文件charsetName- 字符编码- 返回:
- 文件内容字符串
-
readFileToBytesByStream
读取文件内容, 返回 byte[]- 参数:
filePath- 文件路径- 返回:
- 文件内容 byte[]
-
readFileToBytesByStream
读取文件内容, 返回 byte[]- 参数:
file- 文件- 返回:
- 文件内容 byte[]
-
readFileToBytesByChannel
通过 FileChannel, 读取文件内容, 返回 byte[]- 参数:
filePath- 文件路径- 返回:
- 文件内容 byte[]
-
readFileToBytesByChannel
通过 FileChannel, 读取文件内容, 返回 byte[]- 参数:
file- 文件- 返回:
- 文件内容 byte[]
-
readFileToBytesByMap
通过 MappedByteBuffer, 读取文件内容, 返回 byte[]- 参数:
filePath- 文件路径- 返回:
- 文件内容 byte[]
-
readFileToBytesByMap
通过 MappedByteBuffer, 读取文件内容, 返回 byte[]- 参数:
file- 文件- 返回:
- 文件内容 byte[]
-
copyLarge
复制 InputStream 到 OutputStream- 参数:
inputStream-InputStream读取流outputStream-OutputStream写入流- 返回:
- bytes number
-