|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectorg.jiucai.appframework.common.deflater.zip.Zip
public class Zip
提供对单个文件与目录的压缩,并支持是否需要创建压缩源目录、中文路径
| 字段摘要 | |
|---|---|
protected static Logs |
log
|
| 构造方法摘要 | |
|---|---|
Zip()
|
|
| 方法摘要 | |
|---|---|
static void |
doUncompressFile(String inFileName)
|
static String |
getFileName(String f)
|
static void |
main(String[] args)
|
static InputStream |
readFile(String archive,
String filePath)
读取压缩包中的指定文件 |
static void |
setEncoding(String charset)
默认编码 UFT-8 设置为 UTF-8 时,压缩包的注释乱码,但可以正常使用 unzip / unzip2( Java API 标准解压缩) 类解压文件 设置为 GBK 时,压缩包的注释正常,只能是用 unzip 方法解压缩 |
static void |
unzip(String archive,
String decompressDir)
使用 org.apache.tools.zip.ZipFile 解压文件,它与 java 类库中的 java.util.zip.ZipFile 使用方式是一新的,只不过多了设置编码方式的 接口。 |
static void |
unzip2(String archive,
String decompressDir)
使用 java api 中的 ZipInputStream 类解压文件,但如果压缩时采用了 org.apache.tools.zip.ZipOutputStream时,而不是 java 类库中的 java.util.zip.ZipOutputStream时,该方法不能使用,原因就是编码方 式不一致导致,运行时会抛如下异常: java.lang.IllegalArgumentException at java.util.zip.ZipInputStream.getUTF8String(ZipInputStream.java:290) 当然,如果压缩包使用的是java类库的java.util.zip.ZipOutputStream 压缩而成是不会有问题的,但它不支持中文 |
static void |
zip(String src,
String archive)
|
static void |
zip(String src,
String archive,
String comment)
压缩文件夹或文件 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
protected static Logs log
| 构造方法详细信息 |
|---|
public Zip()
| 方法详细信息 |
|---|
public static void setEncoding(String charset)
charset -
public static void zip(String src,
String archive)
throws FileNotFoundException,
IOException
FileNotFoundException
IOException
public static void zip(String src,
String archive,
String comment)
throws FileNotFoundException,
IOException
src - archive - comment - 压缩包注释
FileNotFoundException
IOException
public static InputStream readFile(String archive,
String filePath)
throws IOException
archive - 压缩包文件filePath - 指定的文件名
IOException
public static void unzip(String archive,
String decompressDir)
throws IOException,
FileNotFoundException,
ZipException
archive - 压缩包路径decompressDir - 解压路径
IOException
FileNotFoundException
ZipExceptionpublic static void doUncompressFile(String inFileName)
public static String getFileName(String f)
public static void unzip2(String archive,
String decompressDir)
throws FileNotFoundException,
IOException
archive - 压缩包路径decompressDir - 解压路径
FileNotFoundException
IOException
public static void main(String[] args)
throws Exception
args -
IOException
Exception
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||