Re: java.util.zip on hpux



On 1 Dec 2005 12:54:30 -0800, ctippur@xxxxxxxxx wrote, quoted or
indirectly quoted someone who said :

>I have used java.util.zip package to compress a folder recursively
>(which contains sub folders) using the package java.util.zip. It
>created a zip file after that. I am unable to unzip OR gunzip this file
>on HPUX.

See what you can do with Jar.exe.

See http://mindprod.com/jgloss/zip.html
for how to write some code to unpack a zip.

Here is a sample of the sort of thing you need:

/**
* Unpack one zip file, and put all its contents into the target
directory.
* It may contain some deadwood, but so long as we process zips in
the
* proper order the deadwood will be over written.
*
* @param zd
* Which zip file to unpack.
* @throws IOException
*/
public static void unpackOneZip ( MiniZD zd ) throws IOException
{

// can't use ZipInputStream, since getSize would fail
File zf = new File( zd.getZipFilename( ZD.ON_TARGET ) );
ZipFile zip = new ZipFile( zf );
// for each element in the zip
// can't use for:each, only works with Iterator not
Enumeration.
for ( Enumeration e = zip.entries(); e.hasMoreElements(); )
{
ZipEntry entry = (ZipEntry)e.nextElement();
String elementName = entry.getName();
Replicator.doing( "unpacking: " + elementName );
// inside zip, uses / names.
File elementFile = new File(
ConfigForReceiver.RECEIVER_BASE_DIR,
elementName.replace( '/', File.separatorChar ) );
IO.ensureDirectoryExists( elementFile.getParent() );
// test for deleted marker, possibly null
if ( "deleted".equals( entry.getComment() ) )
{
elementFile.delete();
StatsForReceiver.deletedFilesCount++ ;
}
else
{
ft.copy( zip.getInputStream( entry ), elementFile );
elementFile.setLastModified( entry.getTime() );
StatsForReceiver.receivedFilesCount++ ;
}
} // end for each element in the zip

zip.close();
} // end unpackOneZip

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



Relevant Pages

  • Re: While statement
    ... public static void main throws IOException ... private means that no other classes can acces this particular class, ... And when you only need one or two classes from a package, ... You shouldn't have a method throw an exception unless ...
    (comp.lang.java.programmer)
  • SUMMARY - (Partial) - Unpack Solaris packages on other UNIXes
    ... package is actually a cpio archive. ... unpack all the files. ... cpio archives stuck together, topped with a few lines of header. ... > on an other UNIX? ...
    (SunManagers)
  • Re: fc6 java
    ... On Friday 27 October 2006 05:52, Uno Engborg wrote: ... package from Sun ... unpack it in /opt and set JAVA_HOME and update the PATH variable by ...
    (Fedora)
  • Re: mxCGIPython binaries for Python 2.3.5
    ... > to download this package onto a SunOS system, unpack and ... > have Python up and running? ...
    (comp.lang.python)
  • Re: traits question
    ... the link exists in the lib directory when i tar up the package. ... what does it unpack as then? ...
    (comp.lang.ruby)