File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Programatically creating directory in zip file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Programatically creating directory in zip file" Watch "Programatically creating directory in zip file" New topic
Author

Programatically creating directory in zip file

Logeswaran Radhakrishnan
Greenhorn

Joined: Apr 20, 2010
Posts: 13
Hi

I have a two strings A and B and a document ,i want to create a folder Structure A->B->document in the ZIP file programatically.
Help me out how to create a folder in the zip file with the given string .



Thanks and Regards
Logeswaran
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

Just add the directory in the name in the ZipEntry: directory/file.txt


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Logeswaran Radhakrishnan
Greenhorn

Joined: Apr 20, 2010
Posts: 13
Hi Rob

Thanks for the immdiate reply.But that doesnt help me out.
Let me brief my scenario.

Consider that my file resides in C:\\file.doc.I ll fetch that file name programatically by using file.list().

After this the user will give two strings as input .Only Strings not the directories .

I have to make two directories in the zip file for the given two strings inside which i have to add my file( C:\\file.doc) .




Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

Search in this forum for my posts regarding zipping. I've posted (pseudo)code for recursively zipping entire directories before.
Logeswaran Radhakrishnan
Greenhorn

Joined: Apr 20, 2010
Posts: 13
Hi Rob,
I have gone through your postings.Using it what i have done is i have created a directory structure for the given strings by
.


Inside the dir2 folder i have copied some files.When i tried to zip the dir2 it shows the following error.



I think i have to set the folder access permissions programatically.Is that right?

Help me out to solve the issue.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

You shouldn't mix \\ and / inside file names.
Logeswaran Radhakrishnan
Greenhorn

Joined: Apr 20, 2010
Posts: 13
Thanks Rob the issue is resolved..
 
Don't get me started about those stupid light bulbs.
 
subject: Programatically creating directory in zip file
 
Similar Threads
Adding files to jar
Creating .ear file from zip file
Zip a folder programatically ??
Creating zip containg both files and folders
Ruthlessly smash the bug...but where is it?