| |
这本是别人的东西,我只是修改了中文问题。在这个基础上改一下就可以压缩多个文件和目录,甚至可以写一个winzip之类的东东哦,有兴趣的可以研究一下。 import java.io.*; import java.util.zip.*; /** * @version version 1.3 */ public class w0514{ public static void main(string[] args){ try{ bufferedreader in=new bufferedreader( new inputstreamreader(new fileinputstream(args[0]),"iso8859_1")); fileoutputstream f=new fileoutputstream(args[1]+".zip"); checkedoutputstream ch=new checkedoutputstream(f,new crc32()); zipoutputstream out=new zipoutputstream( new bufferedoutputstream(ch)); int c; out.putnextentry(new zipentry(args[0])); while((c=in.read())!=-1) out.write(c); in.close(); out.close(); } catch(exception e){ e.printstacktrace(); } } }
|
|