Java压缩类库的使用 3.Apache Ant中的打包、压缩类库
inkfish原创,请勿商业性质转载,转载请注明来源(http://blog.csdn.net/inkfish)。
这里需要关注的是BZIP2格式,经过测试,总是无法正确压缩,原因未知,而apache commons bzip2格式的文件压缩正常。(来源:http://blog.csdn.net/inkfish)
Ant 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.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Enumeration;
import org.apache.commons.io.IOUtils;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipFile;
import org.apache.tools.zip.ZipOutputStream;
public class AntZipCompress extends Compress {
@Override
protected void doCompress(File srcFile, File destFile) throws IOException {
ZipOutputStream zout = null;
InputStream is = null;
try {
is = new BufferedInputStream(new FileInputStream(srcFile), bufferLen);
zout = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(destFile), bufferLen));
zout.putNextEntry(new ZipEntry(srcFile.getName()));
IOUtils.copy(is, zout);
zout.closeEntry();
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(zout);
}
}
@Override
protected void doDecompress(File srcFile, File destDir) throws IOException {
ZipFile zipFile = new ZipFile(srcFile);
try {
@SuppressWarnings("unchecked")
Enumeration<ZipEntry> enums = zipFile.getEntries();
while (enums.hasMoreElements()) {
ZipEntry entry = enums.nextElement();
InputStream is = new BufferedInputStream(zipFile.getInputStream(entry), bufferLen);
OutputStream os = null;
try {
os = new BufferedOutputStream(new FileOutputStream(new File(destDir, entry.getName())), bufferLen);
IOUtils.copy(is, os);
} finally {
IOUtils.closeQuietly(is);
IOUtils.clo
相关文档:
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列
......
如何读取资源文件:
(一)
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
- ......
最近的Devoxx大会上,Java 7将包含闭包的消息令很多人感到振奋——这将做为一个独立的JSR被实现。在众多Java 7新的语言特性中,有一些现在已经完成了。Devoxx大会的一位参会者在博客中报告了下面这些Java 7已经完成的7大新功能:
1)对集合类的语言支持;
2)自动资源管理;
3)改进的通用实例创建类型推断;
......
一:J2SE 面向对象-封装、继承、多态
内存的分析
递归
集合类、泛型、自动打包与解包、Annotation
IO
多线程、线程同步
TCP/UDP
AWT、事件模型、匿名类
正则表达式
反射机制
2:数据库(Oracle或者MySQL)
SQL语句
多表连接,内外连接, 子查询等
管理表、视图、索引、序列、约束等
树状结构存储
存储过 ......