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

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


相关文档:

sql 2005 存储过程分页 java 代码

 create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',         
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列 ......

jxl.jar包简介/java操作excel jxl.jar下载

 下载地址:
http://www.andykhan.com/jexcelapi/ 当前的最高版本是2.6。
真实下载地址:
http://www.andykhan.com/jexcelapi/download.html
作者的网站上对它的特征有如下描述: 
● 支持Excel 95-2000的所有版本 
● 生成Excel 2000标准格式 
● 支持字体、数字 ......

Java操作Excel:book保护

    Excel的book保护是很常用的,主要是不想让别人修改Excel的时候用。这样能够避免恶意随便修改数据,提高数据的可行度。
    那么JAVA来实现设置book保护怎么做呢?
    查找了几种常见的JAVA操作Excel的一些包,大体结果如下:
    1. POI
  &nbs ......

在java中利用rhino执行javascript

以rhino中执行QQ邮箱的safeauth.js为例
js代码地址:http://res.qqmail.com/zh_CN/htmledition20091127/js/safeauth.js
(1)导入相应类
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import com.sun.phobos.script.javascript.RhinoScriptEngineFactory;
(2)解析JS
ScriptEngine ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号