Re: java.util.zip on hpux
- From: Roedy Green <my_email_is_posted_on_my_website@xxxxxxxxxxxxxx>
- Date: Thu, 01 Dec 2005 21:32:07 GMT
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.
.
- Follow-Ups:
- Re: java.util.zip on hpux
- From: ctippur
- Re: java.util.zip on hpux
- References:
- java.util.zip on hpux
- From: ctippur
- java.util.zip on hpux
- Prev by Date: Use 2 dimensional array to instantiate new objects
- Next by Date: Re: Use 2 dimensional array to instantiate new objects
- Previous by thread: java.util.zip on hpux
- Next by thread: Re: java.util.zip on hpux
- Index(es):
Relevant Pages
|
|