import java.io.*;
import java.util.zip.*;
class zip {
public static void main(string args[]) throws ioexception {
byte b[] = new byte[512];
zipoutputstream zout = new zipoutputstream(system.out);
for(int i = 0; i < args.length; i ++) {
inputstream in = new fileinputstream(args[i]);
zipentry e = new zipentry(args[i].replace(file.separatorchar,'/'));
zout.putnextentry(e);
int len=0;
while((len=in.read(b)) != -1) {
zout.write(b,0,len);
}
zout.closeentry();
print(e);
}
zout.close();
}
public static void print(zipentry e){
printstream err = system.err;
err.print("added " + e.getname());
if (e.getmethod() == zipentry.deflated) {
long size = e.getsize();
if (size > 0) {
long csize = e.getcompressedsize();
long ratio = ((size-csize)*100) / size;
err.println(" (deflated " + ratio + "%)");
}
else {
err.println(" (deflated 0%)");
}
}
else {
err.println(" (stored 0%)");
}
}
}
闽公网安备 35060202000074号