• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Raj Paila
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34073
335
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Raj Paila
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic