Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes I/O and Streams and the fly likes ZipInputStream Throws Illegalargument exception for diacritics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "ZipInputStream Throws Illegalargument exception for diacritics " Watch "ZipInputStream Throws Illegalargument exception for diacritics " New topic

ZipInputStream Throws Illegalargument exception for diacritics

meghala devi

Joined: Oct 07, 2010
Posts: 3

If I run the below program with the zip file which has some files with diacritic characters (e.g 1-2GF-969##JÖN.pdf) , I get IllegalArgumentException.

My application has to support all languages. So, we set encoding to UTF-8

All languages work fine. But the problem comes when reading diacritic characters.

I tried using alternatives to zip input stream, like arcmexer and apache commons compress, but it does not help.

Please help me with this.

private static void readUsingJava() {
ZipInputStream zis;
try {
zis = new ZipInputStream(new FileInputStream("C:\\"));
ZipEntry ze;
while ((ze = zis.getNextEntry()) != null) {
System.out.println("Name of the File Is :: " + ze.getName());
} catch (FileNotFoundException e) {
} catch (IOException e) {

Stack Trace

<at com.hp.gpp.massupload.util.FileHandler.getTotalNoOfFilesinZip(>
<at com.hp.gpp.massupload.dao.DocumentDAO.updateDocuments(>
<at com.hp.gpp.massupload.handler.LoadProcessor.updateLoad(>
<at com.hp.gpp.massupload.action.UpdateLoadAction.execute(>
<at org.apache.struts.action.RequestProcessor.processActionPerform(>
<at org.apache.struts.action.ActionServlet.process(>
<at org.apache.struts.action.ActionServlet.doPost(>
<at javax.servlet.http.HttpServlet.service(>
<at javax.servlet.http.HttpServlet.service(>
<at weblogic.servlet.internal.StubSecurityHelper$>
<at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(>
<at weblogic.servlet.internal.ServletStubImpl.execute(>
<at weblogic.servlet.internal.TailFilter.doFilter(>
<at weblogic.servlet.internal.FilterChainImpl.doFilter(>
<at com.hp.gpp.massupload.filter.EncodingFilter.doFilter(>
<at weblogic.servlet.internal.FilterChainImpl.doFilter(>
<at com.hp.websat.timber.transaction.TransactionLoggingFilter.doFilter(>
<at weblogic.servlet.internal.FilterChainImpl.doFilter(>
<at weblogic.servlet.internal.WebAppServletContext$>
<at weblogic.servlet.internal.WebAppServletContext.securedExecute(>
<at weblogic.servlet.internal.WebAppServletContext.execute(>
<Error.jsp :: Setting archive file to null>

Apache commons compress.

I used Apache commons compress. It supports Chinese, but gives problem with diacritics. The characters read are not displayed properly. I can see boxes instead of diacritics, like INVID J?NK?

But Chinese characters are displayed properly
Chinese?? ???.pdf

In the web-logic server also, i have set encoding
export LC_CTYPE=en_US.utf8

Kindly help me with this

ZipArchiveInputStream zin = new ZipArchiveInputStream(objInputStream, "UTF-8", true);
ZipArchiveEntry zipArchiveEntry = null;

while((zipArchiveEntry = zin.getNextZipEntry()) != null)
log.debug("File name to be set is :: "+entry.getName());

Darryl Burke

Joined: May 03, 2008
Posts: 5090

Meghala, welcome to the Ranch. Asking the same question all over the net doesn't change the answer I gave you yesterday. Heck, sometimes it doesn't even change the answerers.

Are there more cross posts, other than this one I already know about?

In future, please BeForthrightWhenCrossPostingToOtherSites.

Also answered here

Couldn't open this page, SO seems to be having a problem

luck, db
There are no new questions, but there may be new answers.
meghala devi

Joined: Oct 07, 2010
Posts: 3
Hi Darryl,

Thanks a lot for your help and sorry for posting in many sites. I needed solution urgently. So i did it. Henceforth, i will mention reference to other sites as you suggested.

This works fine with Apache commons compress and Winzip - latest version - 14.5.
I tried with evaluation version of WinZIP.

We have got license for Winzip 9 only. It does not work with Winzip 9 and apache :-)
So, I'm trying to find some alternative solutions. If you know, kindly help.

I agree. Here's the link:
subject: ZipInputStream Throws Illegalargument exception for diacritics
It's not a secret anymore!