The Artima Developer Community
Sponsored Link

Java Buzz Forum
Creating gzipped archives from Java

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Chris Winters

Posts: 931
Nickname: cwinters
Registered: Jul, 2003

Daytime: Java hacker; nighttime: Perl hacker; sleeptime: some of both.
Creating gzipped archives from Java Posted: May 18, 2004 1:38 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Chris Winters.
Original Post: Creating gzipped archives from Java
Feed Title: cwinters.com
Feed URL: http://www.cwinters.com/search/registrar.php?domain=jroller.com®istrar=sedopark
Feed Description: Chris Winters on Java, programming and technology, usually in that order.
Latest Java Buzz Posts
Latest Java Buzz Posts by Chris Winters
Latest Posts From cwinters.com

Advertisement
Using the Javatar library and the standard GZIP output stream you can create gzipped tarballs pretty easily. Since the Javatar library doesn't include any examples of creating an archive and you can spend a while spinning your wheels about how to most easily do this, here you go:
File destArchive = new File( "somefile.tar.gz" );
TarArchive archive = new TarArchive(
    new GZIPOutputStream( new FileOutputStream( destArchive ) )
);
// assume we've got a collection of 'someFiles' from somewhere
for ( Iterator it = someFiles.iterator(); it.hasNext(); )
{
    File recordFile = (File)it.next();
    TarEntry entry = new TarEntry( recordFile );
    entry.setName( recordFile.getName() );     // no leading dir info
    archive.writeEntry( entry, false );
}
archive.closeArchive();

Read: Creating gzipped archives from Java

Topic: JSF for me while we all ponder EJB 3 Previous Topic   Next Topic Topic: [May 7, 2004 14:12 PDT] 15 Links

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use