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面试题大全带答案,欢迎大家参考!isoracle.ismajordiffereneceoracle8iandoracle9i.mesomethingurself.setellmeaboutoops.issingleinheritance.ismultipleinheritance.java...
-
Java学习如何走出第一步
Java语言作为静态面向对象编程语言的代表,极好地实现了面向对象理论,允许程序员以优雅的思维方式进行复杂的编程。下面是小编整理的关于Java学习如何走出第一步,欢迎大家参考!Java开发平台的种类很多,在这篇文章中我主要以J2SE为例子。J2SE几乎是开发所有Java应用...
-
java认证考试培训内容
SunJava认证分为两个级别:Sun认证Java程序员和Sun认证Java开发员。下面是小编整理的关于java认证考试培训内容,欢迎大家参考!Struts多模块的应用在使用到struts多模块的一些小经验可以和大家分享下,关于多module的配置就不说了,只需要用不同的config,作为默认modul...
-
2017年JAVA工程师考试试题及答案
Java是一种可以撰写跨平台应用程序的面向对象的程序设计语言。下面是小编整理的关于JAVA工程师考试试题及答案,欢迎大家参考!1).下列代码的执行结果是:publicclassTest2{publicstaticvoidmain(Stringargs[]){tln(5/2);}}A.2.5B.2.0C.2.50D.2正确答案:D2).在Java中...