FileUtils

class FileUtils
    author: Blankj
    blog  : http://blankj.com
    time  : 2016/05/03
    desc  : utils about file

Types

OnReplaceListener
Link copied to clipboard
interface OnReplaceListener

Functions

copyDir
Link copied to clipboard
open fun copyDir(srcDir: File, destDir: File, listener: FileUtils.OnReplaceListener): Boolean
Copy the directory.
open fun copyDir(srcDirPath: String, destDirPath: String, listener: FileUtils.OnReplaceListener): Boolean
Copy the directory.
copyFile
Link copied to clipboard
open fun copyFile(srcFile: File, destFile: File, listener: FileUtils.OnReplaceListener): Boolean
Copy the file.
open fun copyFile(srcFilePath: String, destFilePath: String, listener: FileUtils.OnReplaceListener): Boolean
Copy the file.
createFileByDeleteOldFile
Link copied to clipboard
open fun createFileByDeleteOldFile(file: File): Boolean
Create a file if it doesn't exist, otherwise delete old file before creating.
open fun createFileByDeleteOldFile(filePath: String): Boolean
Create a file if it doesn't exist, otherwise delete old file before creating.
createOrExistsDir
Link copied to clipboard
open fun createOrExistsDir(file: File): Boolean
Create a directory if it doesn't exist, otherwise do nothing.
open fun createOrExistsDir(dirPath: String): Boolean
Create a directory if it doesn't exist, otherwise do nothing.
createOrExistsFile
Link copied to clipboard
open fun createOrExistsFile(file: File): Boolean
Create a file if it doesn't exist, otherwise do nothing.
open fun createOrExistsFile(filePath: String): Boolean
Create a file if it doesn't exist, otherwise do nothing.
deleteAllInDir
Link copied to clipboard
open fun deleteAllInDir(dir: File): Boolean
Delete the all in directory.
open fun deleteAllInDir(dirPath: String): Boolean
Delete the all in directory.
deleteDir
Link copied to clipboard
open fun deleteDir(dir: File): Boolean
Delete the directory.
open fun deleteDir(dirPath: String): Boolean
Delete the directory.
deleteFile
Link copied to clipboard
open fun deleteFile(file: File): Boolean
Delete the file.
open fun deleteFile(srcFilePath: String): Boolean
Delete the file.
deleteFilesInDir
Link copied to clipboard
open fun deleteFilesInDir(dir: File): Boolean
Delete all files in directory.
open fun deleteFilesInDir(dirPath: String): Boolean
Delete all files in directory.
deleteFilesInDirWithFilter
Link copied to clipboard
open fun deleteFilesInDirWithFilter(dir: File, filter: FileFilter): Boolean
Delete all files that satisfy the filter in directory.
open fun deleteFilesInDirWithFilter(dirPath: String, filter: FileFilter): Boolean
Delete all files that satisfy the filter in directory.
getDirLength
Link copied to clipboard
open fun getDirLength(dir: File): Long
Return the length of directory.
open fun getDirLength(dirPath: String): Long
Return the length of directory.
getDirName
Link copied to clipboard
open fun getDirName(file: File): String
Return the file's path of directory.
open fun getDirName(filePath: String): String
Return the file's path of directory.
getDirSize
Link copied to clipboard
open fun getDirSize(dir: File): String
Return the size of directory.
open fun getDirSize(dirPath: String): String
Return the size of directory.
getFileByPath
Link copied to clipboard
open fun getFileByPath(filePath: String): File
Return the file by path.
getFileCharsetSimple
Link copied to clipboard
open fun getFileCharsetSimple(file: File): String
Return the charset of file simply.
open fun getFileCharsetSimple(filePath: String): String
Return the charset of file simply.
getFileExtension
Link copied to clipboard
open fun getFileExtension(file: File): String
Return the extension of file.
open fun getFileExtension(filePath: String): String
Return the extension of file.
getFileFromBytes
Link copied to clipboard
open fun getFileFromBytes(b: Array<Byte>, outputFile: String): File
将byte数组转成File对象
getFileLastModified
Link copied to clipboard
open fun getFileLastModified(file: File): Long
Return the time that the file was last modified.
open fun getFileLastModified(filePath: String): Long
Return the time that the file was last modified.
getFileLength
Link copied to clipboard
open fun getFileLength(file: File): Long
Return the length of file.
open fun getFileLength(filePath: String): Long
Return the length of file.
getFileLines
Link copied to clipboard
open fun getFileLines(file: File): Int
Return the number of lines of file.
open fun getFileLines(filePath: String): Int
Return the number of lines of file.
getFileMD5
Link copied to clipboard
open fun getFileMD5(file: File): Array<Byte>
Return the MD5 of file.
open fun getFileMD5(filePath: String): Array<Byte>
Return the MD5 of file.
getFileMD5ToString
Link copied to clipboard
open fun getFileMD5ToString(file: File): String
Return the MD5 of file.
open fun getFileMD5ToString(filePath: String): String
Return the MD5 of file.
getFileName
Link copied to clipboard
open fun getFileName(file: File): String
Return the name of file.
open fun getFileName(filePath: String): String
Return the name of file.
getFileNameNoExtension
Link copied to clipboard
open fun getFileNameNoExtension(file: File): String
Return the name of file without extension.
open fun getFileNameNoExtension(filePath: String): String
Return the name of file without extension.
getFileSize
Link copied to clipboard
open fun getFileSize(file: File): String
Return the length of file.
open fun getFileSize(filePath: String): String
Return the length of file.
isDir
Link copied to clipboard
open fun isDir(file: File): Boolean
Return whether it is a directory.
open fun isDir(dirPath: String): Boolean
Return whether it is a directory.
isFile
Link copied to clipboard
open fun isFile(file: File): Boolean
Return whether it is a file.
open fun isFile(filePath: String): Boolean
Return whether it is a file.
isFileExists
Link copied to clipboard
open fun isFileExists(file: File): Boolean
Return whether the file exists.
open fun isFileExists(filePath: String): Boolean
Return whether the file exists.
listFilesInDir
Link copied to clipboard
open fun listFilesInDir(dir: File): List<File>
Return the files in directory.
open fun listFilesInDir(dirPath: String): List<File>
Return the files in directory.
open fun listFilesInDir(dir: File, isRecursive: Boolean): List<File>
Return the files in directory.
open fun listFilesInDir(dirPath: String, isRecursive: Boolean): List<File>
Return the files in directory.
listFilesInDirWithFilter
Link copied to clipboard
open fun listFilesInDirWithFilter(dir: File, filter: FileFilter): List<File>
Return the files that satisfy the filter in directory.
open fun listFilesInDirWithFilter(dirPath: String, filter: FileFilter): List<File>
Return the files that satisfy the filter in directory.
open fun listFilesInDirWithFilter(dir: File, filter: FileFilter, isRecursive: Boolean): List<File>
Return the files that satisfy the filter in directory.
open fun listFilesInDirWithFilter(dirPath: String, filter: FileFilter, isRecursive: Boolean): List<File>
Return the files that satisfy the filter in directory.
moveDir
Link copied to clipboard
open fun moveDir(srcDir: File, destDir: File, listener: FileUtils.OnReplaceListener): Boolean
Move the directory.
open fun moveDir(srcDirPath: String, destDirPath: String, listener: FileUtils.OnReplaceListener): Boolean
Move the directory.
moveFile
Link copied to clipboard
open fun moveFile(srcFile: File, destFile: File, listener: FileUtils.OnReplaceListener): Boolean
Move the file.
open fun moveFile(srcFilePath: String, destFilePath: String, listener: FileUtils.OnReplaceListener): Boolean
Move the file.
rename
Link copied to clipboard
open fun rename(file: File, newName: String): Boolean
Rename the file.
open fun rename(filePath: String, newName: String): Boolean
Rename the file.