Java压缩类库的使用 2.JDK中的打包、压缩类库
inkfish原创,请勿商业性质转载,转载请注明来源(http://blog.csdn.net/inkfish)。
这里忽略了jar,因为jar实质上属于zip压缩。(来源:http://blog.csdn.net/inkfish)
JDK ZLIB压缩:(来源:http://blog.csdn.net/inkfish)
package study.inkfish.compress;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
public class JdkZLIBCompress extends Compress {
@Override
protected void doCompress(File srcFile, File destFile) throws IOException {
OutputStream out = null;
InputStream is = null;
try {
is = new BufferedInputStream(new FileInputStream(srcFile), bufferLen);
out = new DeflaterOutputStream(new BufferedOutputStream(new FileOutputStream(destFile), bufferLen));
IOUtils.copy(is, out);
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(out);
}
}
@Override
protected void doDecompress(File srcFile, File destDir) throws IOException {
InputStream is = null;
OutputStream os = null;
try {
File destFile = new File(destDir, FilenameUtils.getBaseName(srcFile.toString()));
is = new InflaterInputStream(new BufferedInputStream(new FileInputStream(srcFile), bufferLen));
os = new BufferedOutputStream(new FileOutputStream(destFile), bufferLen);
IOUtils.copy(is, os);
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(os);
}
}
}
JDK ZIP压缩(仅适用于压缩一个文件):(来源:http://blog.csdn.net/inkfish)
package study.inkfish.compress;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOExcep
相关文档:
在你的代码里调用了一些资源文件,如图片,音乐等,在调试环境或单独运行的时候可以正常显示或播放,而一旦打包到jar文件中,这些东东就再也出不来了,除非把这个jar放到原来未打包以前的目录下,但通常jar是单独发布的。
[关键字] java jar文件包 资源
可能有不少初学者会有这样的困惑:在你的代码里调用了 ......
最近项目中遇到了上移下移操作的一个操作,以前也看到过,但一直没有去研究过,这次项目中遇到了,也就去研究了一把,其实实现原理也挺简单的,说白了就是
要记录数据库里的要进行排序表的总记录数量,然后根据循环的次数,多写几个隐藏变量,进行上移下移操作的时候进行判断就可以了。
&n ......
本项目用到的技术是ssh,ajax框架dwr,工作流等
遇到的问题是业务流程不熟悉,技术上和团队成员有些差距(但我相信自己会完成任务)
sql语句的编写
思路问题,只要有思路,就会有方法,做软件也需要奇思妙想啊哈哈;
开发过程也是不断学习的过程;
最近遇到了一个session和database不同步的问题,解决的方法是将 ......
inkfish原创,请勿商业性质转载,转载请注明来源(http://blog.csdn.net/inkfish)。
压缩是编程中常见的技巧,多用于大文件压缩,数据流压缩等。在Java类库中,内置了jar、ZIP、GZIP、ZLIB等的支持(见java.util.zip、java.util.jar包)。另外在Apache项目下Ant中ant.jar的org.apache.tools.tar、org.apache.tool ......