All Projects → bitstorm → tiny-zip

bitstorm / tiny-zip

Licence: Apache-2.0 License
The missing Zip library for Java

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to tiny-zip

Archivemounter
Mounts archives like disk images (macOS)
Stars: ✭ 77 (+327.78%)
Mutual labels:  utility, zip
ToGoZip
Android share/sendTo menu implementation "add2Zip"
Stars: ✭ 44 (+144.44%)
Mutual labels:  utility, zip
aspZip
A classic ASP zip and unzip utility class that uses the native zip support from Windows (XP and above) - no components needed
Stars: ✭ 24 (+33.33%)
Mutual labels:  utility, zip
action-sync-node-meta
GitHub Action that syncs package.json with the repository metadata.
Stars: ✭ 25 (+38.89%)
Mutual labels:  utility
EnhanceDiskUtility
SIMBL plugin for Disk Utility that aims to enable Verify / Repair Permissions support
Stars: ✭ 17 (-5.56%)
Mutual labels:  utility
vimclip
Never type outside vim again
Stars: ✭ 70 (+288.89%)
Mutual labels:  utility
lpk
Find go projects/packages in your GOPATH
Stars: ✭ 13 (-27.78%)
Mutual labels:  utility
missing
A utility library for Clojure of functions and macros that complement clojure.core
Stars: ✭ 26 (+44.44%)
Mutual labels:  utility
powerlet
⚡️ Chrome Extension to quickly find and run bookmarklets
Stars: ✭ 17 (-5.56%)
Mutual labels:  utility
ExecutionMaster
Windows utility for intercepting process creation and assigning standard actions to program startup
Stars: ✭ 54 (+200%)
Mutual labels:  utility
cross-unzip
Cross-platform 'native' unzip in Node.js
Stars: ✭ 17 (-5.56%)
Mutual labels:  zip
chai
Don't let your Mac fall asleep, like a sir
Stars: ✭ 54 (+200%)
Mutual labels:  utility
Hytilities
Hypixel-focused Quality of Life mod.
Stars: ✭ 53 (+194.44%)
Mutual labels:  utility
uncompress.js
Uncompress ZIP, RAR, and TAR files with pure JavaScript
Stars: ✭ 79 (+338.89%)
Mutual labels:  zip
react-component-pack
Library that allows you to create context provider groups
Stars: ✭ 32 (+77.78%)
Mutual labels:  utility
cracker-ng
ZIP cracker, CCRYPT cracker, and others to come.
Stars: ✭ 60 (+233.33%)
Mutual labels:  zip
lzbase62
LZ77(LZSS) based compression algorithm in base62 for JavaScript.
Stars: ✭ 38 (+111.11%)
Mutual labels:  zip
oc-bootstrapper
Easily bootstrap a new October CMS project
Stars: ✭ 86 (+377.78%)
Mutual labels:  utility
SimpleCore
.NET C# common/utilities library
Stars: ✭ 11 (-38.89%)
Mutual labels:  utility
proxy-pants
Secured and reliable Proxy based utilities for more or less common tasks.
Stars: ✭ 36 (+100%)
Mutual labels:  utility

TinyZip, the missing Java ZIP library

Java offers support for the ZIP file format through package java.util.zip package since its very first versions. However this kind of support is limited to I/O streams and algorithm implementation, without any utility class for the file system. That's why so many projects (both open and closed source) have their own version of ZipUtils class that tries to fill the gap!
This library aims to finally offer a light, not over-bloated solution that avoids to reinvent the wheel each time we need to work with ZIP files.
In addition, as its name suggest TinyZip has been designed to be as small as possible: it weights less than 15 kb, isn't tiny enough for you :-)?

Technical specs and license

The library is entirely based on Java NIO package and it has no additional dependencies. Java 8 is required as minimum version.
TinyZip is released under under the terms of the Apache Software Foundation license, version 2.0. The text is included in the file LICENSE in the root of the project.

Maven dependency

<dependency>
	<groupId>io.github.bitstorm</groupId>
	<artifactId>tinyzip-core</artifactId>
	<version>1.0.0</version>
</dependency>	

Basic usage

Zipping files

The basic usage requires only the path to the zip file you want to create along with a list of file/folders you want to zip.

TinyZip.zip("/path/to/my/zip/myzip.zip", "/foo/", "/bar/fooBar.txt", "baz.java");

All previous parameters can be also expressed as Path instances:

Path zipPath = ...
Path fooPath = ...
Path barPath = ...
Path bazPath = ...

TinyZip.zip(zipPath, fooPath, barPath, bazPath);

Unzipping files

Unzipping just requires the path to a zip file and the path to a destination folder:

TinyZip.unzip("/path/to/my/zip/myzip.zip", "/dest");

Just like zip method also unzip can be used with class Path instead of String

Path pathTozip = ...
Path destZip = ...

TinyZip.unzip(pathTozip, destZip);

Advanced usage

Zipping/unzipping process can be customized through class ZipParameters. Here is a list of its properties along with a short description:

  • bufferSize: The size in bytes of the buffer used to read/write the zip streams (ZipInputStream and ZipOutputStream). Its default value is 4096.
  • includeBaseFolderName: This flag says if the name of a folder will be included at the root of the zip file. The flag is considered only if we are zipping a single folder, i.e.:
   ZipParameters params = new ZipParameters(false);
   TinyZip.zip("/path/of/my.zip", params, "/path/to/folder")

         Its default value is true

  • progressObserver: The observer that will be notified about the progress of the zip/unzip process. It receives two parameters: a string representing the current file being processed, and a double value indicating the percentage of work done so far. The first parameter is the file we are compressing during zipping operations, while it's the ZipEntry path we are extracting during unzipping operations.

In the next section we will see an example for progressObserver.

Progress monitoring

TinyZip allows to keep track of the progress for the current zip/unzip operation. This can be done specifying an observer in ZipParameters. This observer is a standard Java BiConsumer that takes in input the following two parameters:

  • A double value representing the percentage of work completed so far.
  • A string value representing the path of the last file processed. When we are zipping this value is the path of the last file we have compressed. When we are unzipping this value is the path of the last ZipEntry we have extracted.

For example:

//set a simple observer that prints progress informations on standard output
ZipParameters params = new ZipParameters((percentage, currentFile) 
	-> System.out.println(String.format("%f, done %s", percentage, currentFile)));
	
TinyZip.zip("/path/to/my/zip/myzip.zip", params, "/foo/", "/bar/fooBar.txt", "baz.java");
// do some stuff...
TinyZip.unzip("/path/to/my/zip/myzip.zip", "/foo", params);		

Using streams

Zipping and unzipping operations can also be performed on IO streams object rather than directly on file. This allows to use custom streams to implement advanced functionalities like data encryption or splitting output over multiple files. For example:

//inizialize output stream
CipherOutputStream myChiperOutputStream = ...

TinyZip.zip(myChiperOutputStream, "/foo/", "/bar/fooBar.txt", "baz.java");

//inizialize input stream
CipherInputStream myChiperInputStream = ...

TinyZip.unzip(myChiperInputStream, "/dest");
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].