Herrameinta sencilla para crear un archivo zip
JAVA:
-
/*
-
** a simple ZIP tool
-
** Réal Gagnon
-
** ex. java Zip file.1 file.2> file.zip
-
**
-
*/
-
import java.io.*;
-
import java.util.zip.*;
-
-
class Zip {
-
byte b[] = new byte[512];
-
for(int i = 0; i <args.length; i ++) {
-
zout.putNextEntry(e);
-
int len=0;
-
while((len=in.read(b)) != -1) {
-
zout.write(b,0,len);
-
}
-
zout.closeEntry();
-
print(e);
-
}
-
zout.close();
-
}
-
-
err.print("added " + e.getName());
-
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%)");
-
}
-
}
-
}
Popularidad: 47%

