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

注意:不同系统对应的不同的文件

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

Java 压缩/ 解压 .Z 文件的更多相关文章

  1. 原生java 压缩解压zip文件

    import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import ...

  2. JAVA压缩解压ZIP文件,中文乱码还需要ANT.JAR包

    package zip; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStrea ...

  3. Java压缩/解压.zip、.tar.gz、.tar.bz2(支持中文)

    本文介绍Java压缩/解压.zip..tar.gz..tar.bz2的方式. 对于zip文件:使用java.util.zip.ZipEntry 和 java.util.zip.ZipFile,通过设置 ...

  4. (转载)C#压缩解压zip 文件

    转载之: C#压缩解压zip 文件 - 大气象 - 博客园http://www.cnblogs.com/greatverve/archive/2011/12/27/csharp-zip.html C# ...

  5. java 提取(解压)zip文件中特定后缀的文件并保存到指定目录

    内容简介 本文主要介绍使用ZipFile来提取zip压缩文件中特定后缀(如:png,jpg)的文件并保存到指定目录下. 导入包:import java.util.zip.ZipFile; 如需添加对r ...

  6. java实现解压zip文件,(亲测可用)!!!!!!

    项目结构: Util.java内容: package com.cfets.demo; import java.io.File; import java.io.FileOutputStream; imp ...

  7. java 提取(解压)rar文件中特定后缀的文件并保存到指定目录

    内容简介 本文主要介绍使用junrar来提取rar压缩文件中特定后缀(如:png,jpg)的文件并保存到指定目录下. 支持v4及以下版本压缩文件,不支持v5及以上. 在rar文件上右键,查看属性,在压 ...

  8. java中自己常用到的工具类-压缩解压zip文件

    package com.ricoh.rapp.ezcx.admintoolweb.util; import java.io.File; import java.io.FileInputStream; ...

  9. android压缩解压zip文件

    网上各种方法的收集: 1.上次写了个解压缩功能,但有局限性,比如压缩文件xx.zip 里包括子目录的情况下,执行上次解压缩的功能就不能实现我们想要的效果,于是在网上参考了一下java的解压缩功能.对上 ...

随机推荐

  1. 项目自动化建构工具gradle 入门5——在intellij中做一个gradle的web工程

    之前的几个小节,都是纯手工建文件夹,纯手工拷贝war包,或者纯手工解压个zip看看结果,,,,这还是我写了玩的helloWorld.若是玩大工程.几十个人的团队协同开发时,这么玩,,,,暴躁的程序员估 ...

  2. 字符串编辑距离(Levenshtein距离)算法

    基本介绍 Levenshtein距离是一种计算两个字符串间的差异程度的字符串度量(string metric).我们可以认为Levenshtein距离就是从一个字符串修改到另一个字符串时,其中编辑单个 ...

  3. [No00008F]PLSQL自动登录,记住用户名密码&日常使用技巧

    配置启动时的登录用户名和密码 这是个有争议的功能,因为记住密码会给带来数据安全的问题. 但假如是开发用的库,密码甚至可以和用户名相同,每次输入密码实在没什么意义,可以考虑让PLSQL Develope ...

  4. CentOS系统yum源使用报错:Error: Cannot retrieve repository metadata (repomd.xml) for repository: rpmforge.

    服务器上的yum突然不好使用,使用yum的时候报错如下:[root@bastion-IDC src]# yum list......Could not retrieve mirrorlist http ...

  5. [LeetCode] H-Index II 求H指数之二

    Follow up for H-Index: What if the citations array is sorted in ascending order? Could you optimize ...

  6. [LeetCode] Binary Tree Inorder Traversal 二叉树的中序遍历

    Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tre ...

  7. [LeetCode] Roman to Integer 罗马数字转化成整数

    Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 t ...

  8. laravel实现数据库多库配置,读写分离配置或者多读写分离配置

    'connections' => array( //默认mysql配置,访问test库 'mysql' => array( 'driver' => 'mysql', 'host' = ...

  9. CentOS配置git和maven自动部署java

    #安装Git yum install git #测试是否成功 git -version #正确 #git version 1.7.1 #配置git config --global user.name ...

  10. How to remove null value in json string

    Hi I'm using the below class Public List<string> name; Public List<string> midname; Once ...