使用chilkat解压.Z(unix压缩格式)的压缩文件
来源:互联网 发布:php微信答题 源码 编辑:程序博客网 时间:2024/05/22 06:52
1、当然是导包了
下载地1(官网):https://www.chilkatsoft.com/ 下载地址2:http://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."); } }
阅读全文
1 0
- 使用chilkat解压.Z(unix压缩格式)的压缩文件
- 7z格式多卷压缩文件使用winRAR解压…
- Linux/Unix下各种压缩文件的压缩/解压方法
- Linux/Unix下各种压缩文件的压缩/解压方法
- Linux/Unix下各种压缩文件的压缩/解压方法
- 压缩文件的压缩和解压
- 【unix】常用压缩格式的压缩与解压方法
- java解压7z格式的压缩包
- linux下tar gz bz2 tgz z等众多压缩文件的压缩与解压方法
- linux下tar gz bz2 tgz z等众多压缩文件的压缩与解压方法
- linux下tar gz bz2 tgz z等众多压缩文件的压缩与解压方法
- linux下tar gz bz2 tgz z等众多压缩文件的压缩与解压方法
- linux下tar gz bz2 tgz z等众多压缩文件的压缩与解压方法
- linux下tar gz bz2 tgz z等众多压缩文件的压缩与解压方法
- 7z 命令行 解压 分卷的压缩文件
- 解压.Z压缩文件
- Java解压.7z格式压缩包
- Linux 下常用压缩文件的解压、压缩
- LibRTMP源代码分析1:概述
- MySQL常用函数整理 | 黄乔国PHP
- Python-re 正则 regex 简介
- html5自定义属性data详解及使用方法
- Python2/3 list set性能测试
- 使用chilkat解压.Z(unix压缩格式)的压缩文件
- HTML 简介—1
- 机器学习简介
- 什么样的运维工程师薪水较高, 你知道吗?
- 选择排序的Java实现
- 2014.4新版uboot启动流程分析
- Win7 64位+VS2013+opencv3.0配置
- centos配置nginx防盗链
- 28-字符串的排列