V
valerie.en.davy
Hello,
I've searched the API's but didn't see anything about the following
problem : I'm using java.util.zip to create a zip file containig some
xmls. No trouble creating the zip but when opening it, I see the files
all have the folder structure of the location(where the xmls were)
and where I made the zip file. To avoid this in winrar I normaly
chose in options the "do not store path" option. Can I do this in
java?
TIA, D
private void zip (){
File[] xmls = getFileArray(BASE_PREFIX, XML_EXTENTION);
byte[] buf = new byte[1024];
try {
String outFilename = OUTPUTZIP;
ZipOutputStream out = new ZipOutputStream(new
FileOutputStream(BASEDIR + SLASH + nbrTreated + outFilename));
for (int i=0; i<xmls.length; i++) {
String filename = BASEDIR + SLASH + xmls.getName();
FileInputStream in = new FileInputStream(filename);
out.putNextEntry(new ZipEntry(filename));
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
out.closeEntry();
in.close();
}
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
I've searched the API's but didn't see anything about the following
problem : I'm using java.util.zip to create a zip file containig some
xmls. No trouble creating the zip but when opening it, I see the files
all have the folder structure of the location(where the xmls were)
and where I made the zip file. To avoid this in winrar I normaly
chose in options the "do not store path" option. Can I do this in
java?
TIA, D
private void zip (){
File[] xmls = getFileArray(BASE_PREFIX, XML_EXTENTION);
byte[] buf = new byte[1024];
try {
String outFilename = OUTPUTZIP;
ZipOutputStream out = new ZipOutputStream(new
FileOutputStream(BASEDIR + SLASH + nbrTreated + outFilename));
for (int i=0; i<xmls.length; i++) {
String filename = BASEDIR + SLASH + xmls.getName();
FileInputStream in = new FileInputStream(filename);
out.putNextEntry(new ZipEntry(filename));
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
out.closeEntry();
in.close();
}
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}