meghala devi

Greenhorn
+ Follow
since Oct 07, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by meghala devi

Hi Sathya

Can synchronizing the block of code help?

This ensures that only one thread accesses the file at a time
13 years ago
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.


13 years ago
Hi



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:\\Check.zip"));
ZipEntry ze;
while ((ze = zis.getNextEntry()) != null) {
System.out.println("Name of the File Is :: " + ze.getName());
}
zis.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}



Stack Trace

<java.lang.IllegalArgumentException>
<at java.util.zip.ZipInputStream.getUTF8String(ZipInputStream.java:299)>
<at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:73)>
<at java.util.zip.ZipInputStream.readLOC(ZipInputStream.java:238)>
<at com.hp.gpp.massupload.util.FileHandler.getTotalNoOfFilesinZip(FileHandler.java:153)>
<at com.hp.gpp.massupload.dao.DocumentDAO.updateDocuments(DocumentDAO.java:1995)>
<at com.hp.gpp.massupload.handler.LoadProcessor.updateLoad(LoadProcessor.java:350)>
<at com.hp.gpp.massupload.action.UpdateLoadAction.execute(UpdateLoadAction.java:153)>
<at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)>
<at com.hp.bco.pl.wpa.action.WPARequestProcessor.process(WPARequestProcessor.java:200)>
<at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)>
<at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)>
<at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)>
<at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)>
<at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:225)>
<at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)>
<at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:266)>
<at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)>
<at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)>
<at com.hp.gpp.massupload.filter.EncodingFilter.doFilter(EncodingFilter.java:33)>
<at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)>
<at com.hp.websat.timber.transaction.TransactionLoggingFilter.doFilter(TransactionLoggingFilter.java:113)>
<at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)>
<at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3160)>
<at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)>
<at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)>
<at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1973)>
<at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1880)>
<at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1309)>
<at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)>
<at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)>
<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?PING.zip

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());

}
13 years ago