AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

make a zip/jar file

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
Petterson Mikael
Guest





PostPosted: Fri Jun 17, 2005 7:54 am    Post subject: make a zip/jar file Reply with 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
Christian.Gruen@gmail.com
Guest





PostPosted: Fri Jun 17, 2005 2:36 pm    Post subject: Re: make a zip/jar file Reply with quote



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





PostPosted: Fri Jun 17, 2005 5:03 pm    Post subject: Re: make a zip/jar file Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.