BREAKTHROUGH the limits
Java dependency to simplify process of compressing and decompressing files and folders.
Compressor4j is a Java dependency to simplify process of compressing and decompressing files and folders.
To compress files or folders, you could use as the following example:
public static void write() throws Exception { try { FileCompressor fileCompressor = new FileCompressor(); String[] files = new String[] { "IMG_01.JPG", "/02/IMG_02.JPG", "/03/IMG_03.JPG" }; for (String file : files) { fileCompressor.add(SRC_PATH + file, file); } fileCompressor.setType(CompressionType.JAR); fileCompressor.setLevel(ZipLevel.NORMAL); fileCompressor.setCompressedPath("output.jar"); fileCompressor.compress(); } catch (Exception e) { e.printStackTrace(); } }
To decompress files or folders, you could use as the following example:
public static void read() throws Exception { try { FileCompressor fileCompressor = FileCompressor.read("input.zip"); fileCompressor.decompress("output/"); } catch (Exception e) { e.printStackTrace(); } }
For more information and usages, please visit source code repository: https://github.com/travistran1989/compressor4j