Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / June 2005

Tip: Looking for answers? Try searching our database.

make a zip/jar file

Thread view: 
Petterson Mikael - 17 Jun 2005 08:54 GMT
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...


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.