1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| final int BUFFER = 2048;
byte data[] = new byte[BUFFER];
FileOutputStream dest= new FileOutputStream(chemin);
BufferedOutputStream buff = new BufferedOutputStream(dest);
ZipOutputStream out = new ZipOutputStream(buff);
out.setMethod(ZipOutputStream.DEFLATED);
out.setLevel(9);
String[] files = {"Configurations2/accelerator/current.xml","META-INF/manifest.xml",
"Thumbnails/thumbnail.png", "content.xml", "layout-cache", "manifest.rdf","meta.xml",
"mimetype", "settings.xml", "styles.xml","Object 1/content.xml","Object 1/meta.xml","Object 1/styles.xml","ObjectReplacements/Object 1",
"Object 3/content.xml","Object 3/meta.xml","Object 3/styles.xml","ObjectReplacements/Object 3"};
for(int i=0; i<files.length; i++) {
FileInputStream fi = new FileInputStream(files[i]);
BufferedInputStream buffi = new BufferedInputStream(fi, BUFFER);
ZipEntry entry= new ZipEntry(files[i]);
out.putNextEntry(entry);
int count;
while((count = buffi.read(data, 0, BUFFER)) != -1) {
out.write(data, 0, count);
}
out.closeEntry();
buffi.close();
}
out.close();
} |
Partager