• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Package Question: java.util.zip
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Package Question: java.util.zip


  • Subject: Re: Package Question: java.util.zip
  • From: Colin Clark <email@hidden>
  • Date: Wed, 6 Jul 2005 09:28:17 -0400

Hi Rick,

Here's some basic code I threw together for zipping files using the java.io.zip package. It should be enough to get you started. The Javadocs are helpful in clarifying how the classes work, and there are several tutorials on the Web if you need further details.

public void zipFiles(String pathToFiles, String zipFileName) throws FileNotFoundException, ZipException, IOException {
File directoryOfFilesToZip = new File(pathToFiles);
File[] filesToZip = directoryOfFilesToZip.listFiles();


File zipFile = new File(zipFileName);
ZipOutputStream zipFileStream = new ZipOutputStream(new FileOutputStream(zipFile));


for (int x = 0; x < filesToZip.length; x++) {
String currentFileName = filesToZip[x].getName();
byte[] fileContents = readFileContents(filesToZip[x]);
ZipEntry currentEntry = new ZipEntry(filesToZip [x].getName());
zipFileStream.putNextEntry(currentEntry);
zipFileStream.write(fileContents);
zipFileStream.closeEntry();
}


        zipFileStream.close();
    }

I hope that helps,

Colin

On 5-Jul-05, at 10:13 PM, Rick Langschultz wrote:


Does anyone have a working example with source for either a WebObjects application, JSP, servlet or stand alone binary to extract/encode a zip file. This is one of the features I would love to use in one of my web applications.



Thanks,

Rick

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com


This email sent to email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Package Question: java.util.zip (From: "Rick Langschultz" <email@hidden>)

  • Prev by Date: Re: WO Builder Icons vs. Menues
  • Next by Date: Re: WO Builder Icons vs. Menues
  • Previous by thread: Package Question: java.util.zip
  • Next by thread: Re: Package Question: java.util.zip
  • Index(es):
    • Date
    • Thread