程序包 spring.turbo.io
类 FileUtils
java.lang.Object
spring.turbo.io.FileUtils
- 从以下版本开始:
- 1.1.0
- 作者:
- 应卓
- 另请参阅:
-
方法概要
修饰符和类型方法说明static voidcleanDirectory(File file) 清空目录static voidcleanDirectoryQuietly(File file) 清空目录static void拷贝文件或目录static voidcreateDirectory(File file) 创建目录实例static voidcreateFile(File file) 创建文件实例static FilecreateFile(String first, String... more) 创建Path实例static void删除目录或文件static voiddeleteQuietly(File file) 删除目录或文件static DategetCreationTime(File file) 获取创建时间static DategetLastAccessTime(File file) 获取最后访问static DategetLastModifiedTime(File file) 获取最后更新时间static booleanisDirectory(File file) 判断path是否为目录static booleanisEmptyDirectory(File file) 判断path是否为空目录static booleanisExecutable(File file) 判断path是否为可执行static boolean判断文件或目录是否存在static boolean判断path是否为隐藏目录或文件static booleanisReadable(File file) 判断path是否为可读static booleanisReadableAndWritable(File file) 判断path是否为可读可写static booleanisRegularFile(File file) 判断path是否为一般文件static booleanisSameFile(File f1, File f2) 判断是否是同一个文件static booleanisSymbolicLink(File file) 判断path是否为Linkstatic booleanisWritable(File file) 判断path是否为可写static void移动文件或目录static byte[]读取二进制数据读取所有的行读取所有的行static long获取文件的大小static Path转换为Path实例static void创建文件或更新最后更新时间static voidwriteBytes(File file, byte[] bytes, boolean createIfNotExists, boolean append) 写入二进制数据static voidwriteLines(File file, List<String> lines, boolean createIfNotExists, boolean append) 写入文本数据static voidwriteLines(File file, List<String> lines, Charset charset, boolean createIfNotExists, boolean append) 写入文本数据
-
方法详细资料
-
toPath
转换为Path实例- 参数:
file- file- 返回:
- path
-
createFile
创建Path实例- 参数:
first- 首个pathmore- 其他path- 返回:
- Path实例
-
createFile
创建文件实例- 参数:
file- file- 抛出:
UncheckedIOException- IO异常
-
createDirectory
创建目录实例- 参数:
file- file- 抛出:
UncheckedIOException- IO异常
-
move
移动文件或目录- 参数:
source- 源target- 目标replaceExisting- 覆盖已存在的目标- 抛出:
UncheckedIOException- IO异常
-
copy
拷贝文件或目录- 参数:
source- 源target- 目标replaceExisting- 覆盖已存在的目标- 抛出:
UncheckedIOException- IO异常
-
touch
创建文件或更新最后更新时间- 参数:
file- file- 抛出:
UncheckedIOException- IO异常
-
isExists
判断文件或目录是否存在- 参数:
file- file- 返回:
- 存在时返回
true否则返回false
-
isDirectory
判断path是否为目录- 参数:
file- file- 返回:
- 是目录时返回
true否则返回false
-
isEmptyDirectory
判断path是否为空目录- 参数:
file- file- 返回:
- 是空目录时返回
true否则返回false - 抛出:
UncheckedIOException- IO异常
-
isRegularFile
判断path是否为一般文件- 参数:
file- file- 返回:
- 是一般文件时返回
true否则返回false
-
isSymbolicLink
判断path是否为Link- 参数:
file- file- 返回:
- 是Link时返回
true否则返回false
-
isHidden
判断path是否为隐藏目录或文件- 参数:
file- file- 返回:
- 是隐藏目录或文件时返回
true否则返回false
-
isReadableAndWritable
判断path是否为可读可写- 参数:
file- file- 返回:
- 是可读可写时返回
true否则返回false
-
isReadable
判断path是否为可读- 参数:
file- file- 返回:
- 是可读时返回
true否则返回false
-
isWritable
判断path是否为可写- 参数:
file- file- 返回:
- 是可写时返回
true否则返回false
-
isExecutable
判断path是否为可执行- 参数:
file- file- 返回:
- 是可执行时返回
true否则返回false
-
size
获取文件的大小- 参数:
file- file- 返回:
- 文件尺寸
- 抛出:
UncheckedIOException- IO异常
-
delete
删除目录或文件- 参数:
file- file- 抛出:
UncheckedIOException- IO异常
-
deleteQuietly
删除目录或文件- 参数:
file- file
-
cleanDirectory
清空目录- 参数:
file- file- 抛出:
UncheckedIOException- IO异常
-
cleanDirectoryQuietly
清空目录- 参数:
file- file
-
getCreationTime
获取创建时间- 参数:
file- file- 返回:
- 创建时间
- 抛出:
UncheckedIOException- IO异常
-
getLastModifiedTime
获取最后更新时间- 参数:
file- file- 返回:
- 最后更新时间
- 抛出:
UncheckedIOException- IO异常
-
getLastAccessTime
获取最后访问- 参数:
file- file- 返回:
- 最后访问时间
- 抛出:
UncheckedIOException- IO异常
-
readLines
读取所有的行- 参数:
file- file- 返回:
- 多行数据
- 抛出:
UncheckedIOException- IO异常
-
readLines
读取所有的行- 参数:
file- pathcharset- 字符编码- 返回:
- 多行数据
- 抛出:
UncheckedIOException- IO异常
-
readBytes
读取二进制数据- 参数:
file- file- 返回:
- 文件内容
- 抛出:
UncheckedIOException- IO异常
-
writeBytes
写入二进制数据- 参数:
file- filebytes- 内容createIfNotExists- 没有文件时是否应该创建之append- 是否使用追加写入- 抛出:
UncheckedIOException- IO异常
-
writeLines
public static void writeLines(File file, List<String> lines, boolean createIfNotExists, boolean append) 写入文本数据- 参数:
file- filelines- 文本数据createIfNotExists- 没有文件时是否应该创建之append- 是否使用追加写入- 抛出:
UncheckedIOException- IO异常
-
writeLines
public static void writeLines(File file, List<String> lines, Charset charset, boolean createIfNotExists, boolean append) 写入文本数据- 参数:
file- filelines- 文本数据charset- 字符编码createIfNotExists- 没有文件时是否应该创建之append- 是否使用追加写入- 抛出:
UncheckedIOException- IO异常
-
isSameFile
判断是否是同一个文件- 参数:
f1- file1f2- file2- 返回:
- 结果
- 抛出:
UncheckedIOException- IO异常
-