Two Laptop Bag*
The moose likes Ant, Maven and Other Build Tools and the fly likes Unable to create a ZIP file reading filenames from a text file using ANT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Unable to create a ZIP file reading filenames from a text file using ANT" Watch "Unable to create a ZIP file reading filenames from a text file using ANT" New topic
Author

Unable to create a ZIP file reading filenames from a text file using ANT

Raj Paila
Greenhorn

Joined: Apr 05, 2014
Posts: 2
Hello Experts,

I am trying to build a zip file using ant. Failed to create a zip file by reading the filenames from a text file. The number of file names may vary each time. Please help me with some sample code.

Or a better idea would be appreciated.

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30506
    
150

Raj,
Welcome to CodeRanch!

The zip task lets you use wildcards. If you copy the files you want to zip to a temporary directory before zipping them, you can just specify that directory.

This makes the problem, "how do I loop through the lines in a file to copy them." There's two steps:

1) Call the loadfile task to read the whole file into a property.

2) Call Ant Contrib's foreach task to loop through that property and copy the file to your temporary directory.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Raj Paila
Greenhorn

Joined: Apr 05, 2014
Posts: 2
I treid to make a directory and copied the files using for loop to read the filenames from a text file and then used zip task to make a zip.

Thanks again for your suggestion.

I really appreciate it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to create a ZIP file reading filenames from a text file using ANT