Results 1 to 4 of 4
  1. #1
    acp26b is offline Member
    Join Date
    Jul 2008
    Posts
    8
    Rep Power
    0

    Default java.util.zip Question

    I have a java application that sits in C:\java\app\ The application downloads files and places them in C:\java\app\temp. I want to zip these files and then email them off to a different server. The issue i am having is that when i zip the files it holds on to the folder structure. So when i unzip, it unzips them to whateverDirIamIn\c:\java\app\temp. Is it possible to zip just the files without holding onto the directory?

    If i dont use a temp folder and just store the files in c:\java\app i get the desired results, however i would like to use a temp folder, in case there is a program crash or something i do not want to leave all the files in the .\app folder. I can reduce the file structure by adding the files to the zip with .\temp\filename but that still holds on to the .\temp structure. Any thoughts or ideas are appreciated. Thanks!

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    If you don't want a directory/path for files in the zip file you create,
    don't put them in the ZipEntry() constructor call. Just put in the file name.

  3. #3
    acp26b is offline Member
    Join Date
    Jul 2008
    Posts
    8
    Rep Power
    0

    Default

    Thanks Norm, do you have an example of this? I have been looking at the documentation for Class ZipOutputStream, the only way i can see to get around using ZipEntry() is to use the ZipOutputStream.write(byte[] b, int off, int len) which i think means i would have to handle the files at the byte level, i like using the File class, it is much simpler : )

  4. #4
    acp26b is offline Member
    Join Date
    Jul 2008
    Posts
    8
    Rep Power
    0

    Default

    I was able to find a detailed example of this, thanks for getting me on the correct path Norm. I tried to post the link in case others would like to see it, but i dont have 20 posts so it will not allow me to post a link, sorry.

Similar Threads

  1. java.util.Scanner not recognised
    By pjm35@st-and.ac.uk in forum New To Java
    Replies: 4
    Last Post: 06-07-2008, 04:32 PM
  2. java.util
    By Java Tutorial in forum Java Tutorial
    Replies: 1
    Last Post: 02-07-2008, 02:46 PM
  3. Using java.util.Stack
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-20-2007, 06:17 PM
  4. Using java.util.Formatter
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-16-2007, 03:29 PM
  5. how to use java.util.Properties?
    By christina in forum New To Java
    Replies: 2
    Last Post: 08-03-2007, 06:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •