没有合适的资源?快使用搜索试试~ 我知道了~
手机中如何解压zip文件
需积分: 31 6 下载量 177 浏览量
2011-08-08
11:02:48
上传
评论
收藏 12KB TXT 举报
温馨提示
试读
11页
手机中如何解压zip文件手机中如何解压zip文件手机中如何解压zip文件手机中如何解压zip文件手机中如何解压zip文件
资源推荐
资源详情
资源评论
package com.read.util;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
public class ZipMe {
private static final int BTYPE_NONE = 0;
private static final int BTYPE_DYNAMIC = 2;
private static final int MAX_BITS = 16;
private static final int MAX_CODE_LITERALS = 287;
private static final int MAX_CODE_DISTANCES = 31;
private static final int MAX_CODE_LENGTHS = 18;
private static final int EOB_CODE = 256;
private static final int LENGTH_EXTRA_BITS[] = { 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99 };
private static final int LENGTH_VALUES[] = { 3, 4, 5, 6, 7, 8, 9, 10, 11,
13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131,
163, 195, 227, 258, 0, 0 };
private static final int DISTANCE_EXTRA_BITS[] = { 0, 0, 0, 0, 1, 1, 2, 2,
3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12,
13, 13 };
private static final int DISTANCE_VALUES[] = { 1, 2, 3, 4, 5, 7, 9, 13, 17,
25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049,
3073, 4097, 6145, 8193, 12289, 16385, 24577 };
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
public class ZipMe {
private static final int BTYPE_NONE = 0;
private static final int BTYPE_DYNAMIC = 2;
private static final int MAX_BITS = 16;
private static final int MAX_CODE_LITERALS = 287;
private static final int MAX_CODE_DISTANCES = 31;
private static final int MAX_CODE_LENGTHS = 18;
private static final int EOB_CODE = 256;
private static final int LENGTH_EXTRA_BITS[] = { 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99 };
private static final int LENGTH_VALUES[] = { 3, 4, 5, 6, 7, 8, 9, 10, 11,
13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131,
163, 195, 227, 258, 0, 0 };
private static final int DISTANCE_EXTRA_BITS[] = { 0, 0, 0, 0, 1, 1, 2, 2,
3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12,
13, 13 };
private static final int DISTANCE_VALUES[] = { 1, 2, 3, 4, 5, 7, 9, 13, 17,
25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049,
3073, 4097, 6145, 8193, 12289, 16385, 24577 };
private static final int DYNAMIC_LENGTH_ORDER[] = { 16, 17, 18, 0, 8, 7, 9,
6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
private int curIndex, curByte, curBit;
public final byte[] inflate(byte data[], int startIdx, int size) {
curIndex = startIdx;
byte ret[] = new byte[size];
int idx, bfinal, btype;
idx = bfinal = btype = curByte = curBit = 0;
do {
bfinal = readBits(data, 1);
btype = readBits(data, 2);
if (btype == BTYPE_NONE) {
curBit = 0;
// LEN.
int len = readBits(data, 16);
// NLEN.
readBits(data, 16);
System.arraycopy(data, curIndex, ret, idx, len);
curIndex += len;
idx += len;
} else {
int literalTree[], distanceTree[];
if (btype == BTYPE_DYNAMIC) {
int hlit = readBits(data, 5) + 257;
int hdist = readBits(data, 5) + 1;
int hclen = readBits(data, 4) + 4;
byte lengthBits[] = new byte[MAX_CODE_LENGTHS + 1];
for (int i = 0; i < hclen; i++)
6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
private int curIndex, curByte, curBit;
public final byte[] inflate(byte data[], int startIdx, int size) {
curIndex = startIdx;
byte ret[] = new byte[size];
int idx, bfinal, btype;
idx = bfinal = btype = curByte = curBit = 0;
do {
bfinal = readBits(data, 1);
btype = readBits(data, 2);
if (btype == BTYPE_NONE) {
curBit = 0;
// LEN.
int len = readBits(data, 16);
// NLEN.
readBits(data, 16);
System.arraycopy(data, curIndex, ret, idx, len);
curIndex += len;
idx += len;
} else {
int literalTree[], distanceTree[];
if (btype == BTYPE_DYNAMIC) {
int hlit = readBits(data, 5) + 257;
int hdist = readBits(data, 5) + 1;
int hclen = readBits(data, 4) + 4;
byte lengthBits[] = new byte[MAX_CODE_LENGTHS + 1];
for (int i = 0; i < hclen; i++)
剩余10页未读,继续阅读
资源评论
xing...
- 粉丝: 30
- 资源: 52
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功