compress

The compress algorithm and archive tool for java.

License

License

GroupId

GroupId

com.github.houbb
ArtifactId

ArtifactId

compress
Last Version

Last Version

0.0.6
Release Date

Release Date

Type

Type

jar
Description

Description

compress
The compress algorithm and archive tool for java.
Source Code Management

Source Code Management

https://github.com/houbb/compress

Download compress

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.houbb/compress/ -->
<dependency>
    <groupId>com.github.houbb</groupId>
    <artifactId>compress</artifactId>
    <version>0.0.6</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.houbb/compress/
implementation 'com.github.houbb:compress:0.0.6'
// https://jarcasting.com/artifacts/com.github.houbb/compress/
implementation ("com.github.houbb:compress:0.0.6")
'com.github.houbb:compress:jar:0.0.6'
<dependency org="com.github.houbb" name="compress" rev="0.0.6">
  <artifact name="compress" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.houbb', module='compress', version='0.0.6')
)
libraryDependencies += "com.github.houbb" % "compress" % "0.0.6"
[com.github.houbb/compress "0.0.6"]

Dependencies

compile (3)

Group / Artifact Type Version
com.github.houbb : heaven jar 0.1.87
org.apache.commons : commons-compress jar 1.19
org.tukaani : xz jar 1.8

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

compress

The compress algorithm tool.(常见压缩算法工具类)

Maven Central Build Status Coverage Status

创作背景

压缩是很常见的一个需求,但是使用 apache 的工具类进行压缩,需要自己处理很多事情。

比如文件是否存在,不存在则需要创建,还要循环处理各种信息,这一点也不优雅。

于是,就基于 apache common-compress 进行封装,便于后期使用。

特性

  • fluent api 设计,优雅灵活

  • 极简的工具类 API 设计,一行代码搞定

  • 支持常见归档压缩算法

  • 返回压缩文件字节信息

  • 返回解压文件字节信息

快速开始

环境要求

JDK1.7+

Maven 3.x+

maven 引入

<dependency>
    <groupId>com.github.houbb</groupId>
    <artifactId>compress</artifactId>
    <version>0.0.5</version>
</dependency>

压缩

将 source 路径的文件,压缩为 target 文件。

默认压缩方式为 ZIP。

final String s = "D:\\github\\compress\\src\\test\\resources\\compress_s.txt";
CompressHelper.compress(s);

解压缩

将 source 路径的文件,解压缩到 target 路径下。

默认根据压缩文件后缀自动选择算法。

默认位置为压缩文件所在文件夹下。

final String s = "D:\\github\\compress\\src\\test\\resources\\compress_s.zip";

CompressHelper.uncompress(s);

支持的压缩算法

参见 CompressTypeEnum 枚举类。

目前支持如下几种:

public enum CompressTypeEnum {

    /**
     * 归档系列
     */
    JAR,

    /**
     * 7z 压缩方式
     */
    SEVENZ,

    /**
     * zip 压缩方式
     */
    ZIP,

    /**
     * tar 压缩方式
     */
    TAR,
    ;

}

Versions

Version
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1