使用chilkat解压.Z(unix压缩格式)的压缩文件

1、当然是导包了
下载地1(官网):https://www.chilkatsoft.com/  
下载地址2http://download.csdn.net/download/fantasic_van/9957370
2、直接上代码
static {
        try {
            //System.loadLibrary("chilkat"); 
            System.load("/usr/lib/libchilkat.so");
        } catch (UnsatisfiedLinkError e) {
            logger.info("Native code library failed to load.\n" + e);
            System.exit(1);
        }
    }

这个静态代码块,需要在解压或压缩前执行,目的是引入chilkat动态库文件。
需要注意的问题(重点):

  • 载入库文件有两个函数,System.load 和 System.loadLibrary。
    当使用System.load时,需要输入文件的全路径,例如:System.load(“/tmp/test.so”);
    当使用System.loadlibrary时是在系统的library 的目录中需找复合条件的库文件,可以使用-Djava.library.path=[path]参数,来指定Java程序加载库文件的路径,或者将库文件(.so,.dll)复制到include的默认路径,Linux一般是/usr/lib目录下,当然你可以编辑/etc/ld.so.conf.d/下的文件,设定自己的库查找路径ldconfig -v|grep xxx看看有没有你的动态库。
    Linux还要注意,使用System.loadLibrary(name)方法其中参数内容与Windows有区别,Linux中的的库文件名为libname.so,Windows为name.dll。

  • 我在解决linux的问题中,用的就是System.load(“/tmp/test.so”) 绝对路径,这个方便快捷

  • 使用System.loadlibrary(“xxxx”)时,必须将xxxx.dll库文件放在java.library.path路径中,解决办法有多种,下面列出我的解决办法(windows系统)
    1) 将xxxx.dll放到C:\Windows\System32中即可
    2)使用eclipse配置
    这里写图片描述

3、解决了动态库文件的问题,则可以进行解压和压缩了
  • 压缩
public static void compressFile(String filePath , String destinationPath){
        CkUnixCompress uc = new CkUnixCompress();
        boolean success;
        success = uc.UnlockComponent("Anything for 30-day trial");
        if (success != true) {
            logger.info(uc.lastErrorText());
            return;
        }
        success = uc.CompressFile(filePath, destinationPath);
        if (success != true) {
            logger.info(uc.lastErrorText());
        } else {
            logger.info("Success.");
        }
    }
  • 解压
public static void decompressFile(String filePath , String destinationPath){
        CkUnixCompress uc = new CkUnixCompress();
        boolean success;
        success = uc.UnlockComponent("Anything for 30-day trial");
        if (success != true) {
            logger.info(uc.lastErrorText());
            return;
        }
        success = uc.UncompressFile(filePath, destinationPath);
        if (success != true) {
            logger.info(uc.lastErrorText());
        } else {
            logger.info("Success.");
        }
    }

ps: 这个工具只有30天试用期,如果过期了,需要重新去下载新的版本,大牛也可以破解一下。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值