Android Java压缩Zlib,Gzip,Zip支持J2ME
2010-11-05 00:54:54 来源:WEB开发网if("ZIP".equals(sys_compress))
{
temp = ZipUtil.zip(bContent);
}
MapServerLog.afterMethod();
return temp;
}
catch (IOException e)
{
MapServerLog.exceptionMethod(e);
e.printStackTrace();
}
MapServerLog.afterMethod();
return null;
}
public static byte[] inflate(byte[] bContent)
{
MapServerLog.beforeMethod();
try
{
String sys_compress = ConfigRes.getInstance().get(Const.SYS_COMPRESS);
byte[] temp = null;
if("LZIP".equals(sys_compress))
{
temp = ZipUtil.unZLib(bContent);
}
else
if("GZIP".equals(sys_compress))
{
temp = ZipUtil.unGZip(bContent);
}
else
if("ZIP".equals(sys_compress))
{
temp = ZipUtil.unZip(bContent);
}
MapServerLog.afterMethod();
return temp;
}
catch (IOException e)
{
MapServerLog.exceptionMethod(e);
e.printStackTrace();
}
MapServerLog.afterMethod();
return null;
}
// 输入数据的最大长度
private static final int MAXLENGTH = 102400;
// 设置缓存大小
private static final int BUFFERSIZE = 1024;
// 压缩选择方式:
//
// /** Try o get the best possible compression */
// public static final int COMPRESSION_MAX = JZlib.Z_BEST_COMPRESSION;
//
// /** Favor speed over compression ratio */
// public static final int COMPRESSION_MIN = JZlib.Z_BEST_SPEED;
//
// /** No compression */
// public static final int COMPRESSION_NONE = JZlib.Z_NO_COMPRESSION;
//
赞助商链接