public class ZipUtil extends Object
| 构造器和说明 |
|---|
ZipUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static byte[] |
gzip(byte[] val)
Gzip压缩处理
|
static byte[] |
gzip(File file)
Gzip压缩文件
|
static byte[] |
gzip(String content,
String charset)
Gzip压缩处理
|
static byte[] |
unGzip(byte[] buf)
Gzip解压处理
|
static String |
unGzip(byte[] buf,
String charset)
Gzip解压缩处理
|
static File |
unzip(File zipFile)
解压到文件名相同的目录中
|
static File |
unzip(File zipFile,
File outFile)
解压
|
static File |
unzip(String zipFilePath)
解压到文件名相同的目录中
|
static File |
unzip(String zipFilePath,
String outFileDir)
解压
|
static File |
zip(File srcFile)
打包到当前目录
|
static void |
zip(File srcFile,
File zipFile,
boolean withSrcDir)
对文件或文件目录进行压缩
|
static File |
zip(String srcPath)
打包到当前目录
|
static File |
zip(String srcPath,
String zipPath)
对文件或文件目录进行压缩
不包含被打包目录 |
static File |
zip(String srcPath,
String zipPath,
boolean withSrcDir)
对文件或文件目录进行压缩
|
public static File zip(String srcPath) throws IOException
srcPath - 源文件路径IOExceptionpublic static File zip(File srcFile) throws IOException
srcFile - 源文件或目录IOExceptionpublic static File zip(String srcPath, String zipPath) throws IOException
srcPath - 要压缩的源文件路径。如果压缩一个文件,则为该文件的全路径;如果压缩一个目录,则为该目录的顶层目录路径zipPath - 压缩文件保存的路径,包括文件名。注意:zipPath不能是srcPath路径下的子文件夹IOExceptionpublic static File zip(String srcPath, String zipPath, boolean withSrcDir) throws IOException
srcPath - 要压缩的源文件路径。如果压缩一个文件,则为该文件的全路径;如果压缩一个目录,则为该目录的顶层目录路径zipPath - 压缩文件保存的路径,包括文件名。注意:zipPath不能是srcPath路径下的子文件夹withSrcDir - 是否包含被打包目录IOExceptionExceptionpublic static void zip(File srcFile, File zipFile, boolean withSrcDir) throws IOException
srcFile - 要压缩的源文件或目录。如果压缩一个文件,则为该文件的全路径;如果压缩一个目录,则为该目录的顶层目录路径zipFile - 生成的Zip文件,包括文件名。注意:zipPath不能是srcPath路径下的子文件夹withSrcDir - 是否包含被打包目录IOExceptionpublic static File unzip(File zipFile) throws IOException
zipFile - 压缩文件IOExceptionpublic static File unzip(String zipFilePath) throws IOException
zipFilePath - 压缩文件路径IOExceptionpublic static File unzip(String zipFilePath, String outFileDir) throws IOException
zipFilePath - 压缩文件的路径outFileDir - 解压到的目录IOExceptionpublic static File unzip(File zipFile, File outFile) throws IOException
zipFile - zip文件outFile - 解压到的目录IOExceptionpublic static byte[] gzip(String content, String charset) throws IOException
content - 被压缩的字符串charset - 编码IOExceptionpublic static byte[] gzip(byte[] val)
throws IOException
val - 被压缩的字节流IOExceptionpublic static byte[] gzip(File file) throws IOException
file - 被压缩的文件IOExceptionpublic static String unGzip(byte[] buf, String charset) throws IOException
buf - 压缩过的字节流charset - 编码IOExceptionpublic static byte[] unGzip(byte[] buf)
throws IOException
buf - bufIOExceptionCopyright © 2016. All rights reserved.