Hi,
I have unzipped a lot of jar files into /home/eraonel/tmp_data.
Now I need to package them into one big jar.
My problem is how to get the file name without
'/home/eraonel/tmp_data'-part.
I am using the following code to get the file names:
public static void listAllContent(File dir)throws IOException {
System.out.println(dir.getCanonicalPath());
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i=0; i<children.length; i++) {
listAllContent(new File(dir, children[i]));
}
}
}
If I put all file names in a List and create a jar file the package will
also contain home.eraonel.tmp_data.se.....
Is it possible to avoid this?
cheers,
//mikael
Christian.Gruen@gmail.com - 17 Jun 2005 15:36 GMT
Hi there,
if I got you right, you could just add a statement like..
for (int i=0; i<children.length; i++) {
if(children[i].startsWith("/home/eraonel/tmp_data")) continue;
listAllContent(new File(dir, children[i]));
}
-- CG
Petterson Mikael schrieb:
> Hi,
>
[quoted text clipped - 25 lines]
>
> //mikael
Remi Arntzen - 17 Jun 2005 18:03 GMT
now if I got you right, you could just do this
String fileName = "[filename]";
zipOutputStream.putNextEntry(new ZipEntry(new
File(fileName).getName()));
zipOutputStream.write... write... write...