public final class FoxBaseFileUtils
extends java.lang.Object
author: Blankj
blog : http://blankj.com
time : 2016/05/03
desc : utils about file
| 限定符和类型 | 类和说明 |
|---|---|
static interface |
FoxBaseFileUtils.OnReplaceListener |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
copyDir(java.io.File srcDir,
java.io.File destDir)
Copy the directory.
|
static boolean |
copyDir(java.io.File srcDir,
java.io.File destDir,
FoxBaseFileUtils.OnReplaceListener listener)
Copy the directory.
|
static boolean |
copyDir(java.lang.String srcDirPath,
java.lang.String destDirPath)
Copy the directory.
|
static boolean |
copyDir(java.lang.String srcDirPath,
java.lang.String destDirPath,
FoxBaseFileUtils.OnReplaceListener listener)
Copy the directory.
|
static boolean |
copyFile(java.io.File srcFile,
java.io.File destFile)
Copy the file.
|
static boolean |
copyFile(java.io.File srcFile,
java.io.File destFile,
FoxBaseFileUtils.OnReplaceListener listener)
Copy the file.
|
static boolean |
copyFile(java.lang.String srcFilePath,
java.lang.String destFilePath)
Copy the file.
|
static boolean |
copyFile(java.lang.String srcFilePath,
java.lang.String destFilePath,
FoxBaseFileUtils.OnReplaceListener listener)
Copy the file.
|
static boolean |
createFileByDeleteOldFile(java.io.File file)
Create a file if it doesn't exist, otherwise delete old file before creating.
|
static boolean |
createFileByDeleteOldFile(java.lang.String filePath)
Create a file if it doesn't exist, otherwise delete old file before creating.
|
static boolean |
createOrExistsDir(java.io.File file)
Create a directory if it doesn't exist, otherwise do nothing.
|
static boolean |
createOrExistsDir(java.lang.String dirPath)
Create a directory if it doesn't exist, otherwise do nothing.
|
static boolean |
createOrExistsFile(java.io.File file)
Create a file if it doesn't exist, otherwise do nothing.
|
static boolean |
createOrExistsFile(java.lang.String filePath)
Create a file if it doesn't exist, otherwise do nothing.
|
static boolean |
delete(java.io.File file)
Delete the directory.
|
static boolean |
delete(java.lang.String filePath)
Delete the directory.
|
static boolean |
deleteAllInDir(java.io.File dir)
Delete the all in directory.
|
static boolean |
deleteAllInDir(java.lang.String dirPath)
Delete the all in directory.
|
static boolean |
deleteDir(java.io.File dir)
Delete the directory.
|
static boolean |
deleteDir(java.lang.String dirPath)
Delete the directory.
|
static boolean |
deleteFile(java.io.File file)
Delete the file.
|
static boolean |
deleteFile(java.lang.String srcFilePath)
Delete the file.
|
static boolean |
deleteFilesInDir(java.io.File dir)
Delete all files in directory.
|
static boolean |
deleteFilesInDir(java.lang.String dirPath)
Delete all files in directory.
|
static boolean |
deleteFilesInDirWithFilter(java.io.File dir,
java.io.FileFilter filter)
Delete all files that satisfy the filter in directory.
|
static boolean |
deleteFilesInDirWithFilter(java.lang.String dirPath,
java.io.FileFilter filter)
Delete all files that satisfy the filter in directory.
|
static long |
getDirLength(java.io.File dir)
Return the length of directory.
|
static long |
getDirLength(java.lang.String dirPath)
Return the length of directory.
|
static java.lang.String |
getDirName(java.io.File file)
Return the file's path of directory.
|
static java.lang.String |
getDirName(java.lang.String filePath)
Return the file's path of directory.
|
static java.lang.String |
getDirSize(java.io.File dir)
Return the size of directory.
|
static java.lang.String |
getDirSize(java.lang.String dirPath)
Return the size of directory.
|
static java.io.File |
getFileByPath(java.lang.String filePath)
Return the file by path.
|
static java.lang.String |
getFileCharsetSimple(java.io.File file)
Return the charset of file simply.
|
static java.lang.String |
getFileCharsetSimple(java.lang.String filePath)
Return the charset of file simply.
|
static java.lang.String |
getFileExtension(java.io.File file)
Return the extension of file.
|
static java.lang.String |
getFileExtension(java.lang.String filePath)
Return the extension of file.
|
static long |
getFileLastModified(java.io.File file)
Return the time that the file was last modified.
|
static long |
getFileLastModified(java.lang.String filePath)
Return the time that the file was last modified.
|
static long |
getFileLength(java.io.File file)
Return the length of file.
|
static long |
getFileLength(java.lang.String filePath)
Return the length of file.
|
static int |
getFileLines(java.io.File file)
Return the number of lines of file.
|
static int |
getFileLines(java.lang.String filePath)
Return the number of lines of file.
|
static byte[] |
getFileMD5(java.io.File file)
Return the MD5 of file.
|
static byte[] |
getFileMD5(java.lang.String filePath)
Return the MD5 of file.
|
static java.lang.String |
getFileMD5ToString(java.io.File file)
Return the MD5 of file.
|
static java.lang.String |
getFileMD5ToString(java.lang.String filePath)
Return the MD5 of file.
|
static java.lang.String |
getFileName(java.io.File file)
Return the name of file.
|
static java.lang.String |
getFileName(java.lang.String filePath)
Return the name of file.
|
static java.lang.String |
getFileNameNoExtension(java.io.File file)
Return the name of file without extension.
|
static java.lang.String |
getFileNameNoExtension(java.lang.String filePath)
Return the name of file without extension.
|
static java.lang.String |
getFileSize(java.io.File file)
Return the length of file.
|
static java.lang.String |
getFileSize(java.lang.String filePath)
Return the length of file.
|
static boolean |
isDir(java.io.File file)
Return whether it is a directory.
|
static boolean |
isDir(java.lang.String dirPath)
Return whether it is a directory.
|
static boolean |
isFile(java.io.File file)
Return whether it is a file.
|
static boolean |
isFile(java.lang.String filePath)
Return whether it is a file.
|
static boolean |
isFileExists(java.io.File file)
Return whether the file exists.
|
static boolean |
isFileExists(java.lang.String filePath)
Return whether the file exists.
|
static java.util.List<java.io.File> |
listFilesInDir(java.io.File dir)
Return the files in directory.
|
static java.util.List<java.io.File> |
listFilesInDir(java.io.File dir,
boolean isRecursive)
Return the files in directory.
|
static java.util.List<java.io.File> |
listFilesInDir(java.lang.String dirPath)
Return the files in directory.
|
static java.util.List<java.io.File> |
listFilesInDir(java.lang.String dirPath,
boolean isRecursive)
Return the files in directory.
|
static java.util.List<java.io.File> |
listFilesInDirWithFilter(java.io.File dir,
java.io.FileFilter filter)
Return the files that satisfy the filter in directory.
|
static java.util.List<java.io.File> |
listFilesInDirWithFilter(java.io.File dir,
java.io.FileFilter filter,
boolean isRecursive)
Return the files that satisfy the filter in directory.
|
static java.util.List<java.io.File> |
listFilesInDirWithFilter(java.lang.String dirPath,
java.io.FileFilter filter)
Return the files that satisfy the filter in directory.
|
static java.util.List<java.io.File> |
listFilesInDirWithFilter(java.lang.String dirPath,
java.io.FileFilter filter,
boolean isRecursive)
Return the files that satisfy the filter in directory.
|
static boolean |
moveDir(java.io.File srcDir,
java.io.File destDir)
Move the directory.
|
static boolean |
moveDir(java.io.File srcDir,
java.io.File destDir,
FoxBaseFileUtils.OnReplaceListener listener)
Move the directory.
|
static boolean |
moveDir(java.lang.String srcDirPath,
java.lang.String destDirPath)
Move the directory.
|
static boolean |
moveDir(java.lang.String srcDirPath,
java.lang.String destDirPath,
FoxBaseFileUtils.OnReplaceListener listener)
Move the directory.
|
static boolean |
moveFile(java.io.File srcFile,
java.io.File destFile)
Move the file.
|
static boolean |
moveFile(java.io.File srcFile,
java.io.File destFile,
FoxBaseFileUtils.OnReplaceListener listener)
Move the file.
|
static boolean |
moveFile(java.lang.String srcFilePath,
java.lang.String destFilePath)
Move the file.
|
static boolean |
moveFile(java.lang.String srcFilePath,
java.lang.String destFilePath,
FoxBaseFileUtils.OnReplaceListener listener)
Move the file.
|
static boolean |
rename(java.io.File file,
java.lang.String newName)
Rename the file.
|
static boolean |
rename(java.lang.String filePath,
java.lang.String newName)
Rename the file.
|
public static java.io.File getFileByPath(java.lang.String filePath)
filePath - The path of file.public static boolean isFileExists(java.lang.String filePath)
filePath - The path of file.true: yesfalse: nopublic static boolean isFileExists(java.io.File file)
file - The file.true: yesfalse: nopublic static boolean rename(java.lang.String filePath,
java.lang.String newName)
filePath - The path of file.newName - The new name of file.true: successfalse: failpublic static boolean rename(java.io.File file,
java.lang.String newName)
file - The file.newName - The new name of file.true: successfalse: failpublic static boolean isDir(java.lang.String dirPath)
dirPath - The path of directory.true: yesfalse: nopublic static boolean isDir(java.io.File file)
file - The file.true: yesfalse: nopublic static boolean isFile(java.lang.String filePath)
filePath - The path of file.true: yesfalse: nopublic static boolean isFile(java.io.File file)
file - The file.true: yesfalse: nopublic static boolean createOrExistsDir(java.lang.String dirPath)
dirPath - The path of directory.true: exists or creates successfullyfalse: otherwisepublic static boolean createOrExistsDir(java.io.File file)
file - The file.true: exists or creates successfullyfalse: otherwisepublic static boolean createOrExistsFile(java.lang.String filePath)
filePath - The path of file.true: exists or creates successfullyfalse: otherwisepublic static boolean createOrExistsFile(java.io.File file)
file - The file.true: exists or creates successfullyfalse: otherwisepublic static boolean createFileByDeleteOldFile(java.lang.String filePath)
filePath - The path of file.true: successfalse: failpublic static boolean createFileByDeleteOldFile(java.io.File file)
file - The file.true: successfalse: failpublic static boolean copyDir(java.lang.String srcDirPath,
java.lang.String destDirPath)
srcDirPath - The path of source directory.destDirPath - The path of destination directory.true: successfalse: failpublic static boolean copyDir(java.lang.String srcDirPath,
java.lang.String destDirPath,
FoxBaseFileUtils.OnReplaceListener listener)
srcDirPath - The path of source directory.destDirPath - The path of destination directory.listener - The replace listener.true: successfalse: failpublic static boolean copyDir(java.io.File srcDir,
java.io.File destDir)
srcDir - The source directory.destDir - The destination directory.true: successfalse: failpublic static boolean copyDir(java.io.File srcDir,
java.io.File destDir,
FoxBaseFileUtils.OnReplaceListener listener)
srcDir - The source directory.destDir - The destination directory.listener - The replace listener.true: successfalse: failpublic static boolean copyFile(java.lang.String srcFilePath,
java.lang.String destFilePath)
srcFilePath - The path of source file.destFilePath - The path of destination file.true: successfalse: failpublic static boolean copyFile(java.lang.String srcFilePath,
java.lang.String destFilePath,
FoxBaseFileUtils.OnReplaceListener listener)
srcFilePath - The path of source file.destFilePath - The path of destination file.listener - The replace listener.true: successfalse: failpublic static boolean copyFile(java.io.File srcFile,
java.io.File destFile)
srcFile - The source file.destFile - The destination file.true: successfalse: failpublic static boolean copyFile(java.io.File srcFile,
java.io.File destFile,
FoxBaseFileUtils.OnReplaceListener listener)
srcFile - The source file.destFile - The destination file.listener - The replace listener.true: successfalse: failpublic static boolean moveDir(java.lang.String srcDirPath,
java.lang.String destDirPath)
srcDirPath - The path of source directory.destDirPath - The path of destination directory.true: successfalse: failpublic static boolean moveDir(java.lang.String srcDirPath,
java.lang.String destDirPath,
FoxBaseFileUtils.OnReplaceListener listener)
srcDirPath - The path of source directory.destDirPath - The path of destination directory.listener - The replace listener.true: successfalse: failpublic static boolean moveDir(java.io.File srcDir,
java.io.File destDir)
srcDir - The source directory.destDir - The destination directory.true: successfalse: failpublic static boolean moveDir(java.io.File srcDir,
java.io.File destDir,
FoxBaseFileUtils.OnReplaceListener listener)
srcDir - The source directory.destDir - The destination directory.listener - The replace listener.true: successfalse: failpublic static boolean moveFile(java.lang.String srcFilePath,
java.lang.String destFilePath)
srcFilePath - The path of source file.destFilePath - The path of destination file.true: successfalse: failpublic static boolean moveFile(java.lang.String srcFilePath,
java.lang.String destFilePath,
FoxBaseFileUtils.OnReplaceListener listener)
srcFilePath - The path of source file.destFilePath - The path of destination file.listener - The replace listener.true: successfalse: failpublic static boolean moveFile(java.io.File srcFile,
java.io.File destFile)
srcFile - The source file.destFile - The destination file.true: successfalse: failpublic static boolean moveFile(java.io.File srcFile,
java.io.File destFile,
FoxBaseFileUtils.OnReplaceListener listener)
srcFile - The source file.destFile - The destination file.listener - The replace listener.true: successfalse: failpublic static boolean delete(java.lang.String filePath)
filePath - The path of file.true: successfalse: failpublic static boolean delete(java.io.File file)
file - The file.true: successfalse: failpublic static boolean deleteDir(java.lang.String dirPath)
dirPath - The path of directory.true: successfalse: failpublic static boolean deleteDir(java.io.File dir)
dir - The directory.true: successfalse: failpublic static boolean deleteFile(java.lang.String srcFilePath)
srcFilePath - The path of source file.true: successfalse: failpublic static boolean deleteFile(java.io.File file)
file - The file.true: successfalse: failpublic static boolean deleteAllInDir(java.lang.String dirPath)
dirPath - The path of directory.true: successfalse: failpublic static boolean deleteAllInDir(java.io.File dir)
dir - The directory.true: successfalse: failpublic static boolean deleteFilesInDir(java.lang.String dirPath)
dirPath - The path of directory.true: successfalse: failpublic static boolean deleteFilesInDir(java.io.File dir)
dir - The directory.true: successfalse: failpublic static boolean deleteFilesInDirWithFilter(java.lang.String dirPath,
java.io.FileFilter filter)
dirPath - The path of directory.filter - The filter.true: successfalse: failpublic static boolean deleteFilesInDirWithFilter(java.io.File dir,
java.io.FileFilter filter)
dir - The directory.filter - The filter.true: successfalse: failpublic static java.util.List<java.io.File> listFilesInDir(java.lang.String dirPath)
Doesn't traverse subdirectories
dirPath - The path of directory.public static java.util.List<java.io.File> listFilesInDir(java.io.File dir)
Doesn't traverse subdirectories
dir - The directory.public static java.util.List<java.io.File> listFilesInDir(java.lang.String dirPath,
boolean isRecursive)
dirPath - The path of directory.isRecursive - True to traverse subdirectories, false otherwise.public static java.util.List<java.io.File> listFilesInDir(java.io.File dir,
boolean isRecursive)
dir - The directory.isRecursive - True to traverse subdirectories, false otherwise.public static java.util.List<java.io.File> listFilesInDirWithFilter(java.lang.String dirPath,
java.io.FileFilter filter)
Doesn't traverse subdirectories
dirPath - The path of directory.filter - The filter.public static java.util.List<java.io.File> listFilesInDirWithFilter(java.io.File dir,
java.io.FileFilter filter)
Doesn't traverse subdirectories
dir - The directory.filter - The filter.public static java.util.List<java.io.File> listFilesInDirWithFilter(java.lang.String dirPath,
java.io.FileFilter filter,
boolean isRecursive)
dirPath - The path of directory.filter - The filter.isRecursive - True to traverse subdirectories, false otherwise.public static java.util.List<java.io.File> listFilesInDirWithFilter(java.io.File dir,
java.io.FileFilter filter,
boolean isRecursive)
dir - The directory.filter - The filter.isRecursive - True to traverse subdirectories, false otherwise.public static long getFileLastModified(java.lang.String filePath)
filePath - The path of file.public static long getFileLastModified(java.io.File file)
file - The file.public static java.lang.String getFileCharsetSimple(java.lang.String filePath)
filePath - The path of file.public static java.lang.String getFileCharsetSimple(java.io.File file)
file - The file.public static int getFileLines(java.lang.String filePath)
filePath - The path of file.public static int getFileLines(java.io.File file)
file - The file.public static java.lang.String getDirSize(java.lang.String dirPath)
dirPath - The path of directory.public static java.lang.String getDirSize(java.io.File dir)
dir - The directory.public static java.lang.String getFileSize(java.lang.String filePath)
filePath - The path of file.public static java.lang.String getFileSize(java.io.File file)
file - The file.public static long getDirLength(java.lang.String dirPath)
dirPath - The path of directory.public static long getDirLength(java.io.File dir)
dir - The directory.public static long getFileLength(java.lang.String filePath)
filePath - The path of file.public static long getFileLength(java.io.File file)
file - The file.public static java.lang.String getFileMD5ToString(java.lang.String filePath)
filePath - The path of file.public static java.lang.String getFileMD5ToString(java.io.File file)
file - The file.public static byte[] getFileMD5(java.lang.String filePath)
filePath - The path of file.public static byte[] getFileMD5(java.io.File file)
file - The file.public static java.lang.String getDirName(java.io.File file)
file - The file.public static java.lang.String getDirName(java.lang.String filePath)
filePath - The path of file.public static java.lang.String getFileName(java.io.File file)
file - The file.public static java.lang.String getFileName(java.lang.String filePath)
filePath - The path of file.public static java.lang.String getFileNameNoExtension(java.io.File file)
file - The file.public static java.lang.String getFileNameNoExtension(java.lang.String filePath)
filePath - The path of file.public static java.lang.String getFileExtension(java.io.File file)
file - The file.public static java.lang.String getFileExtension(java.lang.String filePath)
filePath - The path of file.