类 MyUtils
java.lang.Object
com.gdxsoft.easyweb.resources.MyUtils
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明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 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 booleanDelete a filestatic StringgetFileExt(String name) Get the extension form the file namestatic StringgetFileNoExt(String name) Get the file name without extensiongetZipList(String zipFilePath) Get the zip/jar file liststatic Stringhex(byte[] digest) static Stringmd5(byte[] buf) static Stringstatic byte[]readFileBytes(String path) Read the binary contents of the filestatic 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) Unzip 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
-
构造器详细资料
-
MyUtils
public MyUtils()
-
-
方法详细资料
-
md5
-
hex
-
md5
-
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
-
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
-
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 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
-
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
-
buildPaths
Create the paths- 参数:
path- the path- 返回:
- result
-