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 / General / February 2006

Tip: Looking for answers? Try searching our database.

Creating a zip or jar file with directory structure!

Thread view: 
Lee - 13 Feb 2006 13:28 GMT
Hi,

I am trying to (zip or jar) a directory (including empty directories)
using
java.util.zip.* and java.util.jar.*.  I can create zip and jar files
but
when extracted all files appear to be in the root dir of the extracted
zip/jar.  How can i keep the directory structure intact?  Does anyone
have
any examples please?

thanks in advance
lee
Roedy Green - 13 Feb 2006 13:49 GMT
>I am trying to (zip or jar) a directory (including empty directories)
>using
[quoted text clipped - 4 lines]
>have
>any examples please?
see http://mindprod.com/jgloss/zip.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Thomas Kellerer - 13 Feb 2006 14:23 GMT
> I am trying to (zip or jar) a directory (including empty directories)
> using
[quoted text clipped - 4 lines]
> have
> any examples please?

Are you sure this is not a problem with your method of unzipping the files?

Thomas

Signature

It's not a RootKit - it's a Sony

Roedy Green - 13 Feb 2006 15:49 GMT
On Mon, 13 Feb 2006 15:23:50 +0100, Thomas Kellerer
<WVIJEVPANEHT@spammotel.com> wrote, quoted or indirectly quoted
someone who said :

>> when extracted all files appear to be in the root dir of the extracted
>> zip/jar.  How can i keep the directory structure intact?  Does anyone
>> have
>> any examples please?
>
>Are you sure this is not a problem with your method of unzipping the files
use winzip or other archiver to check the structure. The main problem
you run into is trying to unzip files compressed with esoteric
compression algorithms with rather dull Java classes that only know
the basic ones.

See http://mindprod.com/jgloss/compression.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

impaler - 13 Feb 2006 15:26 GMT
> Hi,
>
[quoted text clipped - 9 lines]
> thanks in advance
> lee

Check what Roedy Green has on that great site and as Thomas said check
your unzipping. Check the zip with a 3rd party app (a simple win
explorer will do it) and make sure you don't have the directory
structure there. If everything seems all right, check when adding the
new entry to the ZipOutputStream. It has to contain the full path you
want to see inside the zip file.

for ex:
...
ZipOutputStream zos = new ZipOutputStream(new
FileOutputStream("/test.zip"));
  File f = new File("pathToMyFileToBeZipped");
  //add zip entry to output stream
  zos.putNextEntry(new ZipEntry(f.getAbsolutePath()));
...

use the absolute path, if you want a relative path you will do a
substring on the absolutepath and there you go


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.