利用JAVA API函数实现数据的压缩与解压缩:
http://dev2dev.bea.com.cn/bbs/thread.jspa?forumID=121&threadID=13451&tstart=0
http://dev2dev.bea.com.cn/bbs/thread.jspa?forumID=121&threadID=13451&tstart=0
解决方案 »
- MyEclipse 7.5如何汉化
- Java中怎么调用其他应用程序,比如word
- 用户登陆的问题,小弟先谢了!
- 这样一个java小程序,提示没有main无法运行,请老鸟们指教
- 看THINKIN IN JAVA 第3版 不懂的地方
- 请问关于Toolkit.getDefaultToolkit().getScreenSize()的问题
- 有个小问题请教一下大家!
- 实时要求很高的文本读写(分不够再加,帮忙顶一下)
- 菜鸟高分求经验!
- 在JAVA的APPLET中如何访问SYBASE数据库,并从数据库取出数据,请写详细代码,给分30
- index.do:?? 50
- HttpURLConnection+httpclient
import java.util.*;
import java.util.zip.*;public class ZipCompress {
public static void main(String[] args)
throws IOException {
//Zip
FileOutputStream f =
new FileOutputStream("zip_test.zip");
CheckedOutputStream chos =
new CheckedOutputStream(f, new Adler32());
ZipOutputStream zop = new ZipOutputStream(chos);
for(int i = 0; i < args.length; i++){
zop.putNextEntry(new ZipEntry(args[i]));
FileInputStream fs =
new FileInputStream(args[i]);
BufferedInputStream bf =
new BufferedInputStream(fs);
int temp;
while((temp = bf.read()) != -1){
zop.write(temp);
}
}
zop.close();
//UNZip
CheckedInputStream ck = new CheckedInputStream(
new BufferedInputStream(
new FileInputStream("zip_test.zip")),
new Adler32());
ZipInputStream zis = new ZipInputStream(ck);
ZipEntry ze = zis.getNextEntry();
while(ze != null){
System.out.println(ze);
FileWriter fw = new FileWriter("backup_" + ze.getName());
BufferedWriter bw = new BufferedWriter(fw);
int temp = 0;
while((temp = (int)zis.read()) != -1){
bw.write(temp);
//System.out.write(temp);
}
bw.close();
ze = zis.getNextEntry();
}
zis.close();
ck.close();
}
}
===================================================1要压缩的文件名从args[]中得到,所以你得输入文件名