Java Unzip Chinese name problem

Source: Internet
Author: User

Public list<string> UnZip (string pathstring, String zippathstring) {
Long startTime = System.currenttimemillis ();
list<string> list = new arraylist<> ();
try {
Charset Charset = Charset.forname ("GBK");
Zipinputstream Zin = new Zipinputstream (New FileInputStream (
zippathstring), CharSet);//input source Zip path
Bufferedinputstream Bin = new Bufferedinputstream (Zin);
String Parent = pathstring; Output path (folder directory)
File Fout = null;
ZipEntry entry;
list list = new arraylist ();
try {
while ((entry = Zin.getnextentry ())! = NULL
&&!entry.isdirectory ()) {
String filenamestring = Entry.getname ();
List.add (filenamestring);
Fout = new File (Parent, filenamestring);
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 + "decompression success");
}
Bin.close ();
Zin.close ();
} catch (IOException e) {
E.printstacktrace ();
}
} catch (FileNotFoundException e) {
E.printstacktrace ();
}
Long endTime = System.currenttimemillis ();
SYSTEM.OUT.PRINTLN ("Time Consuming:" + (Endtime-starttime) + "MS");
return list;
}

Java Unzip Chinese name problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.