Java has built-in processing of zip compressed files. Common classes include:
1. zipfile
2. zipinputstream
3. zipoutputstream
4. zipentry
However, the illegalargumentexception exception is reported when processing the Chinese entry in the compressed file. However, this is not because it does not support Chinese characters, but because the text encoding format in the default compressed file is Unicode, common compression tools, such as WinZip/WinRAR, are used to compress the text encoding format in files. Therefore, if you need to process commonly used ZIP files, you must handle them manually.
There are several common methods:
1. Modify the processing method of the related class. The key code is as follows (take zipinputstream as an example ):
Original code: zipentry E = createzipentry (getutf8string (B, 0, Len ));
To:
Zipentry E = NULL;
// Here, encoding is a member variable and can be assigned a value in the build function.
If (encoding = NULL) E = createzipentry (getutf8string (B, 0, Len ));
Else E = createzipentry (new string (B, 0, Len, encoding ));
There are also three replacement methods:
1. Create a replacement class (under the same package name) and replace the class with the same name in rt. jar.
2. Create a replacement class (under the same package name), package it separately and put it in the class path (but some servers can disable packages starting with Java)
3. Create your own class in the application and release it with the application
2. Use the related classes in org.apache.tools.zip of the antpackage, but do not include the corresponding classes of zipinputstream.