Recently in the use of Zip decompression, using JDK1.7 and above when extracting, some files will be reported abnormal
ExceptionIn thread"Main"Java.Lang.IllegalArgumentException:Malformed at Java.Util.Zip.Zipcoder.Tostring(Zipcoder.Java:58)At Java.Util.Zip.ZipFile.Getzipentry(ZipFile.Java:567)At Java.Util.Zip.ZipFile.access$900(ZipFile.Java:61)At Java.Util.Zip.Zipfile$zipentryiterator.Next(ZipFile.Java:525)At Java.Util.Zip.Zipfile$zipentryiterator.Nextelement(ZipFile.Java:500)At Java.Util.Zip.Zipfile$zipentryiterator.Nextelement(ZipFile.Java:481)At zip.Readingarchive.Unzip(Readingarchive.Java:36)At zip.readingarchive. Unzip(readingarchive. Java: (+) at zip. Readingarchive. Unzip(readingarchive. Java:in main. Main. Main(main. Java:+)
the reason is because the file name is caused by the Chinese, and zipfile default use of UTF-8, in the case of decompression non-UTF-8 will be error
Public zipfile (file file, int mode) throws IOException {
This (file, mode, standardcharsets.utf_8);
}
Finally I used the solution for
Charset GBK = Charset.forname ("GBK");
ZipFile zipfile = new ZipFile (Zipfilename, GBK);
Of course this certainly does not apply with all environments, you can use the modified character set to resolve, for informational purposes only.
JAVA Zip Decompression Malformed error