易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

Java NIO API详解

 
Java NIO API详解
在JDK
1.4以前,Java的IO操作集中在java.io这个包中,是基于流的阻塞(blocking)API。对于大多数应用来说,这样的API使用很方
便,然而,一些对性能要求较高的应用,尤其是服务端应用,往往需要一个更为有效的方式来处理IO。从JDK 1.4起,NIO
API作为一个基于缓冲区,并能提供非阻塞(non-blo ......

Java之父:为Java发展惊奇 和脚本语言走得更近

十年前,Sun微系统公司将Java搬到了世人面前,这是首次协助企业建立具有前瞻性的思想的一款软件,随后Java迅猛扩散,深入到计算机业的几乎每个角落。这项技术的幕后英雄,就是本文采访的James Gosling。
上个世纪90年代初,Gosling发起并领导了一个名为Green的项目,此项目最终演变为Java。Java 的基本理念是创造一种可以 ......

JAVA读取资源文件的N种方法

 
如何读取资源文件:
(一)
Properties props = new Properties();   
props.load(new FileInputStream("db.properties"));
(二)
blog.properties文件如下
dbdriver=oracle.jdbc.driver.OracleDriver
dburl=jdbc:oracle:thin:@127.0.0.1:1521:ora92
dbuser=blog
dbpwd=blog
- ......

Java编程基础

 在一个面向对象的系统中,系统的各种功能是由许许多多的不同对象协作完成的。在这种情况下,各个对象内部是如何实现自己的对系统设计人员来讲就不那么重要
了;而各个对象之间的协作关系则成为系统设计的关键。小到不同类之间的通信,大到各模块之间的交互,在系统设计之初都是要着重考虑的,这也是系统设计的主
要 ......

java学习路线图明细

一:J2SE 面向对象-封装、继承、多态
内存的分析
递归
集合类、泛型、自动打包与解包、Annotation
IO
多线程、线程同步
TCP/UDP
AWT、事件模型、匿名类
正则表达式
反射机制
2:数据库(Oracle或者MySQL)
SQL语句
多表连接,内外连接, 子查询等
管理表、视图、索引、序列、约束等
树状结构存储
存储过 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号