类 UFile
java.lang.Object
com.gdxsoft.easyweb.utils.UFile
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static booleanbuildPaths(String path) Create the pathsstatic StringchangeFileExt(String name, String newExt) Change the file extensionstatic voidCopy filestatic voidcreateBinaryFile(String path, byte[] bytes, boolean isOverWrite) Create a binary filestatic StringcreateHashTextFile(String content, String ext, String path, boolean isOverWrite) Create a hash file based on the contentstatic StringGet the MD5 of the filestatic StringcreateMd5File(byte[] bytes, String ext, String path, boolean isOverWrite) Create a binary file based on the MD5 of the binary content, and the saved file name is MD5 + extensionstatic StringcreateMd5File(byte[] bytes, String md5, String ext, String path, boolean isOverWrite) Create a binary file based on the MD5 of the binary content, and the saved file name is MD5 + extensionstatic voidcreateNewTextFile(String fileName, String content) Create a new text filestatic StringcreateSplitDirPath(String name, int len) Split file name or directory name based on the namestatic StringcreateUnGZipHashFile(String base64String, String ext, String path, boolean isOverWrite) Convert GZIP compressed BASE64 encoded string into a filestatic booleanDelete a filestatic StringdigestFile(File file, String digestName) Get the digest of the filestatic StringgetExtFromFileBytes(byte[] buf) Get the extension from the bytes of the filestatic StringgetFileExt(String name) Get the extension form the file namestatic StringgetFileNoExt(String name) Get the file name without extensionstatic File[]Get the files in the parent directory according to the filter, excluding sub directoriesgetZipList(String zipFilePath) Get the zip/jar file liststatic StringGet the MD5 of the filestatic StringreadFileBase64(String path) Convert the file to base64 stringstatic byte[]readFileBytes(String path) Read the binary contents of the filestatic StringreadFileGzipBase64(String path) Convert the file to GZIP compressed base64 stringstatic StringreadFileText(String filePath) Read the file contents(UTF8) from file or resourcestatic byte[]readZipBytes(String zipFilePath, String innerFileName) Read the zip/jar file binary (UTF8)static StringreadZipText(String zipFilePath, String innerFileName) static voidrenameFile(String sourcePathAndName, String newName) Rename the filestatic StringGet the MD5 of the filestatic StringGet the MD5 of the fileUnzip files to the zipFilePath.xxx.unzip dirUnzip files to the target dirstatic StringCompress the file with ZIPstatic voidCompress filesstatic voidCompress the files with ZIPstatic StringCompress the path with ZIP, exclude sub directoriesstatic voidCompress all files in the root directory, including sub directories
-
构造器详细资料
-
UFile
public UFile()
-
-
方法详细资料
-
getExtFromFileBytes
Get the extension from the bytes of the file- 参数:
buf- the bytes of the file- 返回:
- the file extension
-
delete
Delete a file- 参数:
name- The file path and name- 返回:
- result
-
getFileExt
Get the extension form the file name- 参数:
name- the file name- 返回:
- the extension
-
getFileNoExt
Get the file name without extension- 参数:
name- the file name- 返回:
- the file name without extension
-
changeFileExt
Change the file extension- 参数:
name- the file's name and pathnewExt- new extension- 返回:
- new file name and path
-
getFiles
Get the files in the parent directory according to the filter, excluding sub directories- 参数:
rootPath- the parent directoryfilter- filter- 返回:
- the files
-
readFileGzipBase64
Convert the file to GZIP compressed base64 string- 参数:
path- the file name and path- 返回:
- the result
- 抛出:
IOException
-
readFileBase64
Convert the file to base64 string- 参数:
path- the file name and path- 返回:
- the result;
- 抛出:
ExceptionIOException
-
readFileBytes
Read the binary contents of the file- 参数:
path- the file name and path- 返回:
- binary contents
- 抛出:
IOException
-
readFileText
Read the file contents(UTF8) from file or resource- 参数:
filePath- the file name and path- 返回:
- the file contents (UTF8)
- 抛出:
IOException
-
readZipBytes
Read the zip/jar file binary (UTF8)- 参数:
zipFilePath- the zip or jar fileinnerFileName- zip or jar inner path and name- 返回:
- the content of the file in the zip/jar
- 抛出:
IOException
-
getZipList
Get the zip/jar file list- 参数:
zipFilePath- the zip or jar file- 返回:
- The zip file list
- 抛出:
IOException
-
readZipText
- 抛出:
IOException
-
copyFile
Copy file- 参数:
fileFrom- fromfileTo- to- 抛出:
IOException
-
zipFile
Compress the file with ZIP- 参数:
filePath- the file name and path- 返回:
- the ZIP file name and path
- 抛出:
IOException
-
zipPath
Compress the path with ZIP, exclude sub directories- 参数:
path- the path- 返回:
- zipFileName the ZIP file name and path
- 抛出:
IOException
-
zipFiles
Compress the files with ZIP- 参数:
files- the file path and name arrayzipFileName- the ZIP file path and name- 抛出:
IOException
-
zipPaths
Compress all files in the root directory, including sub directories- 参数:
pathRoot- the root directoryzipFileName- the compressed ZIP file path and name- 抛出:
IOException
-
zipFiles
Compress files- 参数:
files- the files arrayzipFileName- the compressed ZIP file path and name- 抛出:
IOException
-
unZipFile
Unzip files to the zipFilePath.xxx.unzip dir- 参数:
zipFilePath- the zip file path and name- 返回:
- list of unziped files
- 抛出:
IOException
-
unZipFile
Unzip files to the target dir- 参数:
zipFilePath- the zip file path and nametargetPath- the unziped dir- 返回:
- list of unziped files
- 抛出:
IOException
-
renameFile
Rename the file- 参数:
sourcePathAndName- the source file name and pathnewName- new file name (exclude path)
-
createHashTextFile
public static String createHashTextFile(String content, String ext, String path, boolean isOverWrite) throws Exception Create a hash file based on the content- 参数:
content- the contentext- the hash file extensionpath- the directory where the hash file is savedisOverWrite- whether to overwrite the hash file- 返回:
- the hash file name, exclude path
- 抛出:
Exception
-
createNewTextFile
Create a new text file- 参数:
fileName- the saved file name and directorycontent- the saved text content (UTF8)- 抛出:
IOException
-
createMd5File
public static String createMd5File(byte[] bytes, String ext, String path, boolean isOverWrite) throws Exception Create a binary file based on the MD5 of the binary content, and the saved file name is MD5 + extension- 参数:
bytes- The binary contentext- The saved file extensionpath- The saved directoryisOverWrite- Whether to overwrite- 返回:
- The saved file name (MD5 + extension), exclude directory
- 抛出:
Exception
-
createMd5File
public static String createMd5File(byte[] bytes, String md5, String ext, String path, boolean isOverWrite) throws Exception Create a binary file based on the MD5 of the binary content, and the saved file name is MD5 + extension- 参数:
bytes- The binary contentmd5- The md5ext- The saved file extensionpath- The saved directoryisOverWrite- Whether to overwrite- 返回:
- The saved file name (MD5 + extension), exclude directory
- 抛出:
Exception
-
createMd5
Get the MD5 of the file- 参数:
file- the file- 返回:
- the MD5 of the file (hex)
-
md5
Get the MD5 of the file- 参数:
file- the file- 返回:
- the MD5 of the file (hex)
-
sha1
Get the MD5 of the file- 参数:
file- the file- 返回:
- the MD5 of the file (hex)
-
sha256
Get the MD5 of the file- 参数:
file- the file- 返回:
- the MD5 of the file (hex)
-
digestFile
Get the digest of the file- 参数:
file- the filedigestName- the digest name (MD2, MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512)- 返回:
- the digest (hex)
-
createBinaryFile
public static void createBinaryFile(String path, byte[] bytes, boolean isOverWrite) throws Exception Create a binary file- 参数:
path- The file name and path to be createdbytes- The saved binaryisOverWrite- Whether to overwrite- 抛出:
Exception
-
createUnGZipHashFile
public static String createUnGZipHashFile(String base64String, String ext, String path, boolean isOverWrite) throws Exception Convert GZIP compressed BASE64 encoded string into a file- 参数:
base64String- the BASE64 encoded stringext- The file extensionpath- The directory of the file is savedisOverWrite- Whether to overwrite- 返回:
- the create file name, exclude path
- 抛出:
Exception
-
createSplitDirPath
Split file name or directory name based on the name- 参数:
name- namelen- split length- 返回:
- the result
-
buildPaths
Create the paths- 参数:
path- the path- 返回:
- result
-