Write a uncompressed class with the following code: Mport java.io. * ;
Import Java.util.zip. * ;
public class Unzipae ... {
static final int BUFFER = 2048;
Zipinputstream zis = null;
String outputdirectory = new string ();
public void Openzipfile (String fileName)
... {
Try
... {
ZiS = new Zipinputstream (
New Bufferedinputstream (
New FileInputStream (FileName));
}
catch (Exception e)
... {
System.out.println (e);
}
}
public void Setoutputdirectory (String directory)
... {
outputdirectory = Directory;
}
public void Unzipfile ()
... {
byte [] barray = new byte [2048];
int len = 2048, CT;
ZipEntry entry;
Try
... {
while ((entry = Zis.getnextentry ())!= null)
... {
FileOutputStream fout = new FileOutputStream (outputdirectory + "/" + entry.getname ());
Bufferedoutputstream bout = new Bufferedoutputstream (Fout, Len);
while (ct = zis.read (barray, 0, Len))!=-1)
... {
Bout.write (barray, 0, CT);
}
Bout.flush ();
Fout.close ();
Bout.close ();
}
Zis.close ();
}
catch (Exception e)
... {
System.out.println (e);
}
}
}
But after writing a test program to run it, the problem came. Unzipae Uzp = new Unzipae ();
Uzp.openzipfile ("D:/test.zip");
Uzp.setoutputdirectory ("D:/output");
Uzp.unzipfile ();
After running, incredibly reported abnormal illegalargumentexception, set breakpoints debugging, found that the exception is in entry = Zis.getnextentry () thrown. I faint, this kind of abnormal how to debug. After a long day of depression, I began to wonder if there was a problem with the compressed file because it was all Chinese-named files in the package, so I changed a zip compression package. The files in the package are all named in English. Test run, everything is OK. HALO!!!! Does Java not support extracting zip files that contain Chinese file names?