public abstract class SimpleFileIOUtil extends Object
| 构造器和说明 |
|---|
SimpleFileIOUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
createFileIfNotExist(File file)
在文件系统创建不存在的文件以及文件所在的目录
|
static boolean |
deleteFile(File file)
递归删除目录下的所有文件及子目录下所有文件
|
static boolean |
deleteFile(String path)
递归删除目录下的所有文件及子目录下所有文件
|
static byte[] |
readFileByByte(File file)
读取文件至内存,一次读取一个字节
|
static byte[] |
readFileByMultiBytes(File file,
int number)
读取文件至内存,一次读取多个字节
|
static void |
readFileToOutputStream(File file,
OutputStream outputStream)
将文件写入输出流
|
static void |
writeFile(String filePath,
byte[] data,
boolean append)
写二进制数据
|
static void |
writeFile(String filePath,
String str,
boolean append)
写字符串
|
public static byte[] readFileByByte(File file) throws FileNotFoundException, FileReadException
file - 被读取的文件FileNotFoundException - 文件不存在FileReadException - 其他读取异常public static byte[] readFileByMultiBytes(File file, int number) throws FileNotFoundException, FileReadException
file - 被读取的文件number - 一次读取的字节数FileNotFoundException - 文件不存在FileReadException - 其他读取异常public static void writeFile(String filePath, String str, boolean append) throws IOException
filePath - 文件路径str - 字符串内容append - 追加模式IOException - IO异常public static void writeFile(String filePath, byte[] data, boolean append) throws IOException
filePath - 文件路径data - 二进制内容append - 追加模式IOException - IO异常public static void readFileToOutputStream(File file, OutputStream outputStream) throws IOException
file - 待写文件outputStream - 目标输出流IOException - 读写异常public static boolean deleteFile(String path)
path - 将要删除的文件目录public static boolean deleteFile(File file)
file - 将要删除的文件public static void createFileIfNotExist(File file) throws IOException
file - 要创建的文件IOException - IO异常Copyright © 2017. All rights reserved.