Java 压缩/ 解压 .Z 文件


1.问题描述

公司项目有需要用 JAVA 解压 .z文件. .z 是 unix 系统常见的压缩文件. 

2.源码

import com.chilkatsoft.CkUnixCompress;

import java.util.StringTokenizer;

/**
 * Created by zzy on 16/12/29.
 */
//import com.chilkatsoft.*;

public class ChilkatExample {
    

    static {
        try {
            System.load("/Users/zzy/IdeaProjects/dk_project/dk_qingdyinlian/qdyl_file/lib/libchilkat.jnilib");
        } catch (UnsatisfiedLinkError e) {
            System.err.println("Native code library failed to load.\n" + e);
            System.exit(1);
        }
    }

    public static void main(String argv[]) {

        String property = System.getProperty("java.library.path");
        StringTokenizer parser = new StringTokenizer(property, ";");
        while (parser.hasMoreTokens()) {
            System.err.println(parser.nextToken());
        }


        CkUnixCompress uc = new CkUnixCompress();

        boolean success;

        //  Any string unlocks the component for the 1st 30-days.
        success = uc.UnlockComponent("Anything for 30-day trial");
        if (success != true) {
            System.out.println(uc.lastErrorText());
            return;
        }
        String file = "/Users/zzy/Downloads/chrome-down/testzip/test/12.txt";

        success = uc.CompressFile(file, file+"hamlet.xml.Z");

        if (success != true) {
            System.out.println(uc.lastErrorText());
        } else {
            System.out.println("Success.");
        }


    }
}

工程目录

我的运行结果

3 . com.chilkatsoft

这个包找了很久才找到,下载链接: chilkatsoft
注意:不同系统对应的不同的文件

(结束) 欢迎关注:农民阿姨


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM