 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Petterson Mikael Guest
|
Posted: Fri Jun 17, 2005 7:54 am Post subject: make a zip/jar file |
|
|
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
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
|
|
| Back to top |
|
 |
Christian.Gruen@gmail.com Guest
|
Posted: Fri Jun 17, 2005 2:36 pm Post subject: Re: make a zip/jar file |
|
|
Hi there,
if I got you right, you could just add a statement like..
for (int i=0; i
if(children[i].startsWith("/home/eraonel/tmp_data")) continue;
listAllContent(new File(dir, children[i]));
}
-- CG
Petterson Mikael schrieb:
| Quote: | 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
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
|
|
|
| Back to top |
|
 |
Remi Arntzen Guest
|
Posted: Fri Jun 17, 2005 5:03 pm Post subject: Re: make a zip/jar file |
|
|
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...
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|