JAVA认证基础知识:Java文件解压缩示例
Java实现压缩文件的解压缩操作,缺点是压缩文件内不能含有文件名为中文的`的文件,否则会出现如下错误:
Exception in thread "main" gALArgumentException: MALFORMED
at ring(Unknown Source)
at LOC(Unknown Source)
at extEntry(Unknown Source)
at ()
代码:
package ;
import ;
import InputStream;
import OutputStream;
import tStream;
import utStream;
import ntry;
import ile;
import nputStream;
public class ZipFileDemo {
@SuppressWarnings("resource")
public static void main(String args[]) throws Exception {
File file = new File("d:" + rator + "");
File outFile = null;
ZipFile zipFile = new ZipFile(file);
ZipInputStream zipInput = new ZipInputStream(new FileInputStream(file));
ZipEntry entry = null;
InputStream input = null;
OutputStream out = null;
while ((entry = extEntry()) != null) {
tln("开始解压缩" + ame() + "文件。。。");
outFile = new File("d:" + rator + ame());
if (!arentFile()ts()) {
arentFile()r();
}
if (!ts()) {
teNewFile();
}
input = nputStream(entry);
out = new FileOutputStream(outFile);
int temp = 0;
while ((temp = ()) != -1) {
//tln(temp);
e(temp);
}
e();
e();
}
tln("Done!");
}
}
-
Java认证辅导:Java实现二叉树遍历算法
Java实现二叉树遍历算法在JAVA中实现二叉树,程序如下://********************************************************************//filename://purpose:testabinarytreewithjava//date:2002/12/18//author:flyfan//ver:0.1//****************************************...
-
Java的基础知识大全
作为java菜鸟,我们首要是学习java基础知识,那么java的基础知识点有哪些,下面随yjbys小编一起来学习一下吧!一:java概述:1991年Sun公司的JamesGosling(詹姆斯·高斯林)等人开始开发名称为Oak的语言,希望用于控制嵌入在有线电视交换盒、PDA等的微处理器;1994年将...
-
Java远程通讯可选技术及原理
一个最基础的问题就是远程服务是怎么通讯的,在Java领域中有很多可实现远程通讯的技术,例如:RMI、MINA、ESB、Burlap、Hessian、SOAP、EJB和JMS等,这些名词之间到底是些什么关系呢,它们背后到底是基于什么原理实现的呢,了解这些是实现分布式服务框架的基础知识,而如果...
-
2017年java考试模拟试题大纲
Sun公司在推出Java之际就将其作为一种开放的技术。全球数以万计的Java开发公司被要求所设计的Java软件必须相互兼容。下面是小编整理的关于java考试模拟试题,希望大家认真阅读!1、编写程序,计算下列分段函数的值。x?(x>=0)y=-x?(x<0)import.*;publicclasstesta{p...