Reputation: 49609
Is there a simple way, either through the Java libraries or a third party library to zip an existing file in Java?
I am already familiar with the approach of creating a ZipOutputStream, adding ZipEntry objects to that, and then reading the data from a stream into the ZipOutputStream, I'm looking for a simpler way to zip up one File. Most likely this is going to be a recommendation for a third party compression library.
Upvotes: 0
Views: 726
Reputation: 3994
The Apache Cayenne project has a pretty simple ZipUtil, you can check out the javadoc here:
http://cayenne.apache.org/doc20/api/cayenne/org/apache/cayenne/util/ZipUtil.html
Looking at the source it only has imports from the Java SDK so it should be easy to just drop into your application:
Upvotes: 4