Http://bugs.sun.com/bugdatabase/view_bug.do? Bug_id = 4415733
Http://bugs.sun.com/bugdatabase/view_bug.do? Bug_id = 4244499
A long-history bug, but sun does not seem to be eager to modify it. But we have to rely on java.
Fortunately, there are more people who are happy to contribute. Fortunately, we also have a lot of open source.
Truezip can help us solve this problem, the URL is https://truezip.dev.java.net/
The following is a piece of code for testing:
[Code]
Import de. schlichtherle. Io. file;
Import de. schlichtherle. Io. fileoutputstream;
Import de.schlichtherle.util.zip. zipfile;
Import de.schlichtherle.util.zip. zipentry;
Import java. Io .*;
Import java. util. enumeration;
Import JUnit. Framework. testcase;
Public class ziptest extends testcase {
Public void testtruezip () throws exception {
// Because it is a French project, the file name contains special characters in French, so use ISO-8859-1
Zipfile = new zipfile ("D:/temp/isl_2_02.zip", "ISO-8859-1 ");
Enumeration enum_entry = zipfile. Entries ();
// Remove the Regexp of the folder path in zipentry. For example, foler/file.txt => file.txt
String Pattern = "^ ([/S _/S]) */";
Int buffer_size = 1024*4;
While (enum_entry.hasmoreelements ()){
Zipentry entry = (zipentry) enum_entry.nextelement ();
System. Out. println ("D:/temp/EXT/" + entry. getname (). replaceall (pattern ,""));
Bufferedinputstream FCM = new bufferedinputstream (zipfile. getinputstream (entry ));
Fileoutputstream Fos = new fileoutputstream (new file ("D:/temp/EXT/" + entry. getname (). replaceall (pattern ,"")));
Byte [] B = new byte [buffer_size];
Int READ = 0;
While (read = FS. Read (B ))! =-1 ){
FOS. Write (B, 0, read );
}
FOS. Close ();
FCM. Close ();
}
}
}
[Code]
Another thing to note is that the import of classes uses drop-in replacements, so the classes such as file actually use de. schlichtherle. classes in the I/O package, instead of Java. class under Io.