Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2009
    Rep Power

    Default Changing Existing Zip file using java


    I need to add some files to existing zip file and download the file.
    I am reading the zip file using ZipInputStream. how to add new files into the zip and download the file?

    Waiting for reply.

    Thanks and Regards,
    Narayanan. G

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Rep Power


    would it be possible to
    - create a temporary folder on the request,
    - expand the existing zip file into this temporary folder.
    - add your additional files to this temporary folder
    - create and stream back a zip file of the contents of the temporary folder (alternatively, could create a zip file in a second temporary location I guess)
    - clean up the temporary folder (and possibly temporary zip file).

    If it is not practical to clean up the temporary folder immediately after the request, you can try storing a session attribute of a List<File> objects that represent these temporary folders that were created by this user during their session, and create a Session Context Listener that on session destroy, looks for this session attribute of list of folders that are temporary folders and remove them.
    another idea is to have an external process or cron scheduled task perform a delete everything older than a given amount of time within the temporary files folder.

Similar Threads

  1. Creating a new projects with existing file strucutre
    By akhare.sandeep in forum Eclipse
    Replies: 1
    Last Post: 01-27-2009, 05:24 PM
  2. Replies: 1
    Last Post: 10-16-2008, 10:56 PM
  3. Writing to excel file erasing existing formatting
    By jmHoekst in forum New To Java
    Replies: 1
    Last Post: 09-16-2008, 06:58 PM
  4. Run J2ME application using existing jar file
    By chale in forum CLDC and MIDP
    Replies: 0
    Last Post: 08-25-2008, 03:11 PM
  5. Reading Binary File and Changing data
    By janakiram.attuluri in forum Advanced Java
    Replies: 1
    Last Post: 12-21-2007, 11:10 AM

Posting Permissions

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