import
java.io.*;
import
java.nio.charset.Charset;
import
java.util.zip.ZipEntry;
import
java.util.zip.ZipInputStream;
public class
zipDecompresssion {
public static void
main(String[] args){
long
startTime=System.
currentTimeMillis
();
try
{
ZipInputStream Zin=
new
ZipInputStream(
new
FileInputStream(
"D:
\\
study
\\
个人文件.zip"
), Charset.
forName
(
"GBK"
));
//输入源zip路径
BufferedInputStream Bin=
new
BufferedInputStream(Zin);
String Parent=
"D:
\\
study"
;
//输出路径(文件夹目录)
File Fout=
null
;
ZipEntry entry;
try
{
try
{
System.
out
.println(
"entity:"
+Zin.getNextEntry());
while
((entry = Zin.getNextEntry())!=
null
){
Fout=
new
File(Parent,entry.getName());
if
(!Fout.exists()){
(
new
File(Fout.getParent())).mkdirs();
}
FileOutputStream out=
new
FileOutputStream(Fout);
BufferedOutputStream Bout=
new
BufferedOutputStream(out);
int
b;
while
((b=Bin.read())!=-
1
){
Bout.write(b);
}
Bout.close();
out.close();
System.
out
.println(Fout+
"解压成功"
);
}
}
catch
(IOException e) {
e.printStackTrace();
}
Bin.close();
Zin.close();
}
catch
(IOException e) {
//
TODO Auto-generated catch block
e.printStackTrace();
}
}
catch
(FileNotFoundException e) {
//
TODO Auto-generated catch block
e.printStackTrace();
}
long
endTime=System.
currentTimeMillis
();
System.
out
.println(
"耗费时间: "
+(endTime-startTime)+
" ms"
);
}
}