admin管理员组文章数量:1537955
2024年4月4日发(作者:)
ZipUtil(zip压缩工具)
zip(byte[ ] bs) :byte[ ]
以ZIP方式压缩二进制数组。
代码实例
byte[] bs="泽元".getBytes();
byte[] b_1=(bs);
bs: [-26, -77, -67, -27, -123, -125]
b_1: [120, -100, 123, -74, 121, -17, -45, -42, 102, 0, 16, 25, 4,
68]
以UTF-8编码形式输出时为乱码。
gzip(byte[ ] bs) :byte[ ]
以GZIP方式压缩二进制数组。
代码实例
byte[] bs={1,2,3,4,12,123,125};
byte[] b_2=(bs);
bs: [-26, -77, -67, -27, -123, -125]
b_2: [31, -117, 8, 0, 0, 0, 0, 0, 0, 0, 123, -74, 121, -17, -45, -4
2, 102, 0, 96, 17, -52, 84, 6, 0, 0, 0]
zip(String srcFile, String destFile)
以ZIP方式压缩文件。
代码实例
String srcFile="G:" + tor + "";
String destFile="G:" + tor + "";
(srcFile,destFile);
zip(File srcFile, OutputStream destStream)
以ZIP方式压缩文件并输出到指定流。
代码实例
File srcFile = new File("G:" + tor + "");
File destFile=new File("G:" + tor + "");
OutputStream destStream = new FileOutputStream(destFile);
(srcFile,destStream);
zipBatch(String base, String[] srcFiles, String destFile)
将一批文件(文件夹)压缩到一个ZIP文件里,压缩后的路径以base参数为起点。
代码实例
String base="G:";
String f1="G:" + tor + "";
String f2="G:" + tor + "string_";
String f3="G:" + tor + "string_";
String[] srcFiles={f1 ,f2 ,f3 };
String destFile=tor + "";
ch(base,srcFiles, destFile);
zipBatch(String base, String[ ] srcFiles, OutputStream destStream)
将一批文件(文件夹)压缩到一个流里,压缩后的路径以base参数为起点。
代码实例
String base="G:";
String s1="G:" + tor + "";
String s2="G:" + tor + "string_";
String s3="G:" + tor + "string_";
String[] srcFiles={s1 ,s2 ,s3 };
String destFile="G:" + tor + "";
OutputStream destStream = new FileOutputStream(destFile);
ch(base,srcFiles, destStream);
zipBatch(String base, File[ ] srcFiles, OutputStream destStream)
将一批文件(文件夹)压缩到一个指定输出流里,压缩后的路径以base参数为起点。
代码实例
版权声明:本文标题:ZipUtil(zip压缩工具) 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1712222737a349711.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论