Zipping files in a folder using java.util.zip

hi guys,
does any body has the java code for
zipping files in a folder
hi guys,
actually i want to zip no of files in a folder .the folder can also have sub folder
and after zipping when i extract the files manually i should
maintain the same folder structure
does any body has the code
please reply me soon its a bit urgent

hi smeee
i tried running ur code but its not working
here the command
java c:\abc\ zzz.zip
its saying
no files or directories even though there's the
directory present
what's the solution Hi,
Oops that was because of the error check added at the last moment..
Anyway, You need to use the following command to run it :
java ZipUtility c:\abc c:\zzz.zip
Please use the following corrected code:
     Class to zip file(s).
     Requires jdk1.3.1.
     To run use the following command:
     java ZipUtility <directory or file to be zipped> <name of zip file to be created>
     Please specify absolute path names as its parameters while running this program.
import java.util.zip.*;
import java.io.*;
public class ZipUtility {
     ZipOutputStream cpZipOutputStream = null;
     String strSource = "";
     String strTarget = "";
     String strSubstring = "";
     public static void main(String args[]) {
          if(     args == null || args.length < 2) {
               System.out.println("Usage: java ZipUtility <directory or file to be zipped> <name of zip file to be created>");
               return;
          ZipUtility udZipUtility = new ZipUtility();
          udZipUtility.strSource = args[0];
          udZipUtility.strTarget = args[1];
          udZipUtility.zip();
     private void zip(){
                    try
                         File cpFile = new File (strSource);
                         if (!cpFile.isFile() && !cpFile.isDirectory() ) {
                              System.out.println("\nSource file/directory Not Found!");
                              return;
                         if  (cpFile.isDirectory()) {
                              strSubstring = strSource;;
                         } else {
                              strSubstring = "";
                         cpZipOutputStream = new ZipOutputStream(new FileOutputStream(strTarget));
                         cpZipOutputStream.setLevel(9);
                         zipFiles( cpFile);
                         cpZipOutputStream.finish();
                         cpZipOutputStream.close();
                         System.out.println("\n Finished creating zip file " + strTarget + " from source " + strSource);
                    }catch (Exception e){
                         e.printStackTrace();
     private void  zipFiles(File cpFile) {
               if (cpFile.isDirectory()) {
                    File [] fList = cpFile.listFiles() ;
                    for (int i=0; i< fList.length; i++){
                         zipFiles(fList) ;
               } else {
                    try {
                         String strAbsPath = cpFile.getAbsolutePath();
                         String strZipEntryName ="";
                         if (!strSubstring.equals("") ){
                              strZipEntryName = strAbsPath.substring(strSource.length()+1, strAbsPath.length());
                         } else {
                              strZipEntryName = cpFile.getName();
                         byte[] b = new byte[ (int)(cpFile.length()) ];
                         FileInputStream cpFileInputStream = new FileInputStream (cpFile) ;
                         int i = cpFileInputStream.read(b, 0, (int)cpFile.length());
                         ZipEntry cpZipEntry = new ZipEntry(strZipEntryName);
                         cpZipOutputStream.putNextEntry(cpZipEntry );
                         cpZipOutputStream.write(b, 0, (int)cpFile.length());
                         cpZipOutputStream.closeEntry() ;
                    } catch (Exception e) {
                         e.printStackTrace();

Similar Messages

  • How do I estimate time takes to Zip/Unzip using java.util.zip ?

    If I am compressing files or uncompressing zips using java.util.zip is there a way for me to tell the user how long it should take or for perhaps displaying a progress monitor ?

    For unzip use the ZipInputStream and pass it a CountingInputStream that keeps track ofr the number of bytes read from it (you write this). This CountingInputStream extends fileInputStream and as such can provide you with information about the total number of bytes available to be read and the number already read. This can give a crude idea of how much work has been done and how much work still needs to be done. It is inaccurate but should be good enoough for a progress bar
    As for zipping use the ZipOutputStream and pass it blocks of information. Keep track of the number of blocks you have written and the number you still need to write.
    matfud

  • Using java.util.zip.ZipFile

    I have files that are about 4GB (with possible growth in the future) that will be sent to a file system and a java process will be used to unzip them.
    Is there a size limit for unzipping files using java.util.zip.ZipFile?
    annie

    Chicon wrote:
    Hi annie613,
    Indeed, there's a size limit of 2GB for unzipping files, more precisely when the size of the inflated file reaches 2GB !
    Edit : inflated instead of deflated
    Edited by: Chicon on Jun 29, 2009 3:56 PMHmm, this blog says that the current limit of 4GB has been expanded by implementing ZIP64 support in OpenJDK7 build(b55).
    [http://blogs.sun.com/xuemingshen/entry/zip64_support_for_4g_zipfile]

  • Problem in deleting Zip files unzipped using java.util.zip

    I have a static methos for unzipping a zip file. after unzipping the file when i am trying to delete that file using File.delete()its not getting deleted. but when methods like exist(). canRead(), canWrite() methods are returning true what can be the possible problem ? i had closed all the streams after unzipping operation Please go through the following code.
    public static boolean unzipZipFile(String dir_name, String zipFileName) {
    try {
    ZipFile zip = new ZipFile(zipFileName);
    Enumeration entries = zip.entries();
    while (entries.hasMoreElements()) {
    ZipEntry entry = (ZipEntry) entries.nextElement();
    // got all the zip entries here
    // now has to process all the files
    // first all directories
    // then all the files
    if (entry.isDirectory()) {
    // now the directories are created
    File buf=new File(dir_name,entry.getName());
    buf.mkdirs();
    continue;
    }// now got the dirs so process the files
    entries = zip.entries();
    while(entries.hasMoreElements()) {
    // now to process the files
    ZipEntry entry = (ZipEntry) entries.nextElement();
    if (!entry.isDirectory()){
    File buf=new File(dir_name,entry.getName());
    copyInputStream(
    zip.getInputStream(entry),
    new BufferedOutputStream(
    new FileOutputStream(buf)));}
    } catch (IOException e) {
    e.printStackTrace();
    return false;
    return true;
    now i am trying to call this method to unzip a zip file
    public static void main (String arg[]){
    unzipZipFile("C:/temp","C:/tmp.zip");
    java.io.File filer = new File("C:/tmp.zip");
    System.out.println (filer.canRead());
    System.out.println (filer.canWrite());
    System.out.println (filer.delete());
    Please tell me where my program is going wrong ?

    Thanks .. the problem is solved... i was not closing the Zip file .. rather i was trying to close all the other streams that i used for IO operaion ... thanks a lot

  • IOException java.util.zip.ZipException: error in opening zip file

    Hi Folks,
    In my application one Zip file will be placed in the server. to unzip that zip file i have used java.util.Zip.
    It is working fine.but some times it gets the following error.
    **IOException java.util.zip.ZipException: error in opening zip file**
    why is it so? but very rarely. I couldnt identify the exact scenario, where it causes the problem.
    Normally that zip file contains set of images of customer.
    Please share your inputs.
    Thanks,
    Balu.

    Thanks for ur reply.
    EJB is not used in my application.
    VC++ application at customer side prepares the zip file, and it will upload that zip to te server using ftp.
    After uploading done, at the server end one java program(contains main function) will access that folder to unzip.
    Thanks,
    Balu.

  • Webb Exception - java.util.zip.ZipException: error in opening zip file

              I am tring to run my Servlet with myWAR.war. So I started first installing the CookieCounter example that came with weblogic, I did exactly as the document said but I getting the following exception:
              Thu Jan 04 11:26:45 MST 2001:<E> <HTTP> Error reading Web application '/weblogic/myserver/cookieWar.war'
              java.util.zip.ZipException: error in opening zip file
              at java.util.zip.ZipFile.open(Native Method)
              at java.util.zip.ZipFile.<init>(ZipFile.java:69)
              at weblogic.utils.jar.JarFile.<init>(JarFile.java:57)
              at weblogic.utils.jar.JarFile.<init>(JarFile.java:44)
              at weblogic.t3.srvr.HttpServer.loadWARContext(HttpServer.java:582)
              at weblogic.t3.srvr.HttpServer.initServletContexts(HttpServer.java, Compiled Code)
              at weblogic.t3.srvr.HttpServer.start(HttpServer.java:388)
              at weblogic.t3.srvr.T3Srvr.start(T3Srvr.java, Compiled Code)
              at weblogic.t3.srvr.T3Srvr.main(T3Srvr.java:827)
              at java.lang.reflect.Method.invoke(Native Method)
              at weblogic.Server.startServerDynamically(Server.java:99)
              at weblogic.Server.main(Server.java:65)
              at weblogic.Server.main(Server.java:55)
              at weblogic.NTServiceHelper.run(NTServiceHelper.java:19)
              at java.lang.Thread.run(Thread.java:479)
              Has anybody encountered the problem before I created the jar using jar cvf cookieWar.war cookie- under the command line
              

    I have seen problems like this in the past. When you create your war file, try using "jar
              cv0f" so that the jar file won't be compressed...
              mark bouchard wrote:
              > I am having this same error... the strange thing is i have two different ear files...
              > one of them works, the other doesn't. there are NO differences between them according
              > to Araxis Merge... both will deploy, and both show servlets as being registered,
              > but i can only call the servlets from one...
              >
              > what is BEA's suggested way of creating an ear file? on NT and on UNIX please....
              >
              > use the java.util.zip methods? or use a utility like jar or winzip? Personally,
              > i've found this deployment to be HIGHLY flakey at best.... my same ear files
              > deploy perfectly with iPlanet's app server.
              >
              > Mark Spotswood <[email protected]> wrote:
              > >I think this is basically the same as a file not found error.
              > >The error message says it can't open the file. Its looking
              > >for the file under: /weblogic/myserver/cookieWar.war
              > >Make sure the file is in that directory/readable, etc.
              > >--
              > >mark
              > >
              > >Paul Garduno wrote:
              > >
              > >> Just to let you know, I am getting the same error message. I haven't
              > >worked on it but hope to at some point. I would like to know if the
              > >Weblogic people have seen this error.
              > >>
              > >> Paul Garduno
              > >>
              > >> bionic99 wrote:
              > >>
              > >> > I am tring to run my Servlet with myWAR.war. So I started first installing
              > >the CookieCounter example that came with weblogic, I did exactly as
              > >the document said but I getting the following exception:
              > >> > Thu Jan 04 11:26:45 MST 2001:<E> <HTTP> Error reading Web application
              > >'/weblogic/myserver/cookieWar.war'
              > >> > java.util.zip.ZipException: error in opening zip file
              > >> > at java.util.zip.ZipFile.open(Native Method)
              > >> > at java.util.zip.ZipFile.<init>(ZipFile.java:69)
              > >> > at weblogic.utils.jar.JarFile.<init>(JarFile.java:57)
              > >> > at weblogic.utils.jar.JarFile.<init>(JarFile.java:44)
              > >> > at weblogic.t3.srvr.HttpServer.loadWARContext(HttpServer.java:582)
              > >> > at weblogic.t3.srvr.HttpServer.initServletContexts(HttpServer.java,
              > >Compiled Code)
              > >> > at weblogic.t3.srvr.HttpServer.start(HttpServer.java:388)
              > >> > at weblogic.t3.srvr.T3Srvr.start(T3Srvr.java, Compiled Code)
              > >> > at weblogic.t3.srvr.T3Srvr.main(T3Srvr.java:827)
              > >> > at java.lang.reflect.Method.invoke(Native Method)
              > >> > at weblogic.Server.startServerDynamically(Server.java:99)
              > >> > at weblogic.Server.main(Server.java:65)
              > >> > at weblogic.Server.main(Server.java:55)
              > >> > at weblogic.NTServiceHelper.run(NTServiceHelper.java:19)
              > >> > at java.lang.Thread.run(Thread.java:479)
              > >> >
              > >> > Has anybody encountered the problem before I created the jar using
              > >jar cvf cookieWar.war cookie- under the command line
              > >
              

  • Java.util.zip: how to save file type

    HI,
    I have a written a program that zips PDF files and sends them as an attachment via email. This have been running daily for the last 1.5 years with no problems. Recently, some email providers have been striping the attachments or refusing the email, because I have used two file suffix on the attachment, e.g report.pdf.zip. I did this so that when the file is unzipped the .pdf extension remains and file is recognised, otherwise the document is treated as plain text or unknown format. How can I include the filetype in the zipped file, so that I can have report.pdf become report.zip, then when the user unzips the file has report.zip become report.pdf. I know the filetype is stored in the zip header, but I don't know how to do this using java.util.zip. Any help would be appreciated.
    Mike

    You see, zip files are inherently dumb. They don't "actually" have a file system in the strictest sense. The zip file format merely associates a String ID with some bytes. It's all on the client side where the magic happens. if I have three zip entries in a file, these are the entry names.
    1.) somedir/myfile.txt
    2.) someotherdir/myfile.txt
    3.) README
    when a client "unzipper" see these names, it realizes that "/" is a directory separator, so it makes the appropriate directories and places the bytes into files of that given name.
    So all you should have to do is make the zip entry with a name that ends in .pdf The client should do the rest.

  • Unzipping files using java.util

    I am trying to unzip files using java.util.zip
    It works fine when I am trying to unzip a file that is already residing on the server.
    But I want to unzip the file that user will upload to the server .
    My code is uploading zip file to server but not able to unzip this zip file giving error
    java.util.zip.ZipException: error in opening zip file
    What could be the problem
    I am not getting exactly
    Can you give me any clue
    Thanks

    sounds like the uploading is the problem. Are you FTPing the file? If so check that it's being transferred in binary, not ascii.

  • WHY? java.util.zip.ZipException: error in opening zip file

    i'm trying to restart tomcat 4.1 (bin/startup.bat) and getting the following error (windows xp profession machine)
    code:
    java.util.zip.ZipException: error in opening zip file
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:112)
    at java.util.jar.JarFile.<init>(JarFile.java:127)
    at java.util.jar.JarFile.<init>(JarFile.java:65)
    at org.apache.catalina.loader.StandardClassLoader.addRepositoryInternal(StandardClassLoader.java:1082)
    at org.apache.catalina.loader.StandardClassLoader.<init>(StandardClassLoader.java:200)
    at org.apache.catalina.startup.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:202)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:140)
    Bootstrap: Class loader creation threw exception
    java.lang.IllegalArgumentException: addRepositoryInternal: java.util.zip.ZipException: error in opening zip file
         at org.apache.catalina.loader.StandardClassLoader.addRepositoryInternal(StandardClassLoader.java:1110)
         at org.apache.catalina.loader.StandardClassLoader.<init>(StandardClassLoader.java:200)
         at org.apache.catalina.startup.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:202)
         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:140)
    thanks!

    These exceptions occur when opening JAR files (since they are renamed ZIPs). Most likely the file cannot be ffound because you have classpaths setup incorrectly

  • Java.util.zip.ZipException: invalid block type: thrown by adapter-OIM 11g

    Hello Everyone,
    I have deployed an adapter for provisioning to my custom resource and I am calling the code from a process task in the adapter factory.
    The jar for my adapter is place in OIM_HOME/server/JavaTasks .
    Inside the code there is a need to read a configuration xml file which is then parsed using org.apache.commons.digester.Digester parser
    The xml file is present in the src folder.
    The code looks like below:
    URL myURL = MyPlugIn.class.getResource("/com/orgname/appname/xyz.xml");
    InputStream configFileAsStream = myURL.openStream();
    macManager = (MachineManager)digester.parse(configFileAsStream);
    This code works fine when I run it on my local machine, but when I deploy it in OIM I get the following exception:
    java.util.zip.ZipException: invalid block type
         at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:147)
         at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:105)
         at java.io.FilterInputStream.read(FilterInputStream.java:66)
         at oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:377)
         at oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:240)
         at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:222)
         at weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:173)
         at org.apache.commons.digester.Digester.parse(Digester.java:1765)
    Any ideas on why I am getting this exception?
    Is there any other way of going about reading files in adapter code? I have tried reading files by specifying absolute as well as relative paths in OIM but was unable to read them in the adapter code. Any pointers will be of great help.. Thanks!
    Saiesh/-

    Hi,
    Upload if any dependency jar files into database using upload utility as Third Party jar files.
    Regards,
    Raghav

  • Bug on native code of OJVM java.util.zip.CRC32.updateBytes(CRC32.java)

    I want to unzip OpenOffice 1.0 files inside the OJVM but it fails into the native method java.util.zip.CRC32.updateBytes(CRC32.java).
    The first execution of the code runs OK, but the second not.
    After a long wait it shutdown the connection and the oracle trace file shows an stack trace like this:
    *** 2003-04-18 11:31:31.926
    *** SESSION ID:(17.97) 2003-04-18 11:31:31.926
    java.lang.IllegalArgumentException
    at java.util.zip.CRC32.updateBytes(CRC32.java)
    at java.util.zip.CRC32.update(CRC32.java)
    at java.util.zip.ZipInputStream.read(ZipInputStream.java)
    at oracle.xml.parser.v2.XMLByteReader.fillByteBuffer(XMLByteReader.java:354)
    at oracle.xml.parser.v2.XMLUTF8Reader.fillBuffer(XMLUTF8Reader.java:142)
    at oracle.xml.parser.v2.XMLByteReader.saveBuffer(XMLByteReader.java:448)
    at oracle.xml.parser.v2.XMLReader.fillBuffer(XMLReader.java:2012)
    at oracle.xml.parser.v2.XMLReader.skipWhiteSpace(XMLReader.java:1800)
    at oracle.xml.parser.v2.NonValidatingParser.parseMisc(NonValidatingParser.java:305)
    at oracle.xml.parser.v2.NonValidatingParser.parseProlog(NonValidatingParser.java:274)
    at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:254)
    at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:225)
    at com.prism.cms.frontend.EditPropertiesActions.processUpload(EditPropertiesActions.java:1901)
    Exception signal: 11 (SIGSEGV), code: 1 (Address not mapped to object), addr: 0x6d3a74a0, PC: [0x40263600, eomake_reference_to_eobjec
    t()+80]
    Registers:
    %eax: 0x54a54000 %ebx: 0x40429c20 %ecx: 0x54a546bf
    %edx: 0x6d3a7478 %edi: 0x402b27d0 %esi: 0x45c718ac
    %esp: 0xbfffbf20 %ebp: 0xbfffbf48 %eip: 0x40263600
    %efl: 0x00010206
    The code of the java method is:
    public static void processUpload(String id_page, String longname,
    String filename, String filetype,
    String s00)
    throws SQLException {
    Integer p_id = new Integer(id_page);
    String toSource;
    XMLDocument doc = null;
    DOMParser theParser = null;
    InputStream XSLStream = null;
    BufferedWriter out = null;
    #sql { select path||name||'.html' into :toSource from pages where id_page=:p_id };
    if ("Cancel".equalsIgnoreCase(s00)) {
    Jxtp.redirecUrl("/dbprism/ldoc/live/edit.html?p_source="+toSource);
    return;
    if ("no-file".equals(filename) && "no-contenttpye".equals(filetype)) {
    Jxtp.redirecUrl("/dbprism/ldoc/live/edit.html?p_source="+toSource);
    return;
    if ("xml".equalsIgnoreCase(filetype))
    #sql { call CMSj.moveFromUpload(:filename,:p_id) };
    else if ("sxw".equalsIgnoreCase(filetype)) {
    XSLProcessor processor = new XSLProcessor();
    XSLStylesheet theXSLStylesheet = null;
    BLOB locator = null;
    // open sxw file, it will be in zip format with a file named content.xml
    // then convert content.xml to document-v10.dtd with an stylesheet
    #sql { select blob_content into :locator from wpg_document where name = :filename for update };
    ZipInputStream zin = new ZipInputStream(locator.binaryStreamValue());
    ZipEntry entry;
    try {
    while((entry=zin.getNextEntry())!=null)
    if ("content.xml".equalsIgnoreCase(entry.getName())) {
    Integer newVersion;
    CLOB dstDoc;
    CMSDocURLStreamHandlerFactory.enableCMSDocURLs();
    try {
    URL inUrl = new URL("cms:/stylesheets/sxw2document-v10.xsl");
    XSLStream = inUrl.openStream();
    // Create the Stylesheet from the stream
    theXSLStylesheet = processor.newXSLStylesheet(XSLStream);
    // Stores the document processing it with the given stylesheet
    theParser = new DOMParser();
    theParser.setValidationMode(theParser.NONVALIDATING);
    theParser.setBaseURL(new URL("cms:/dtd/"));
    theParser.parse(zin);
    doc = theParser.getDocument();
    #sql { SELECT NVL(MAX(version),0)+1 INTO :newVersion FROM content
    WHERE cn_id_page = :p_id };
    #sql { INSERT INTO content( cn_id_page, version, owner, status, source_file,
    file_size, content, created, modified, created_by,
    modified_by)
    VALUES ( :p_id, :newVersion, sys_context('cms_context','user_id'),
    'Uploaded', :filename, 0 , EMPTY_CLOB(), SYSDATE, SYSDATE,
    sys_context('cms_context','user_id'),
    sys_context('cms_context','user_id')) };
    #sql { SELECT content INTO :dstDoc FROM content
    WHERE cn_id_page = :p_id AND version = :newVersion for update };
    #sql { call DBMS_LOB.trim(:inout dstDoc,0) };
    out = new BufferedWriter(dstDoc.getCharacterOutputStream(),dstDoc.getChunkSize());
    processor.processXSL(theXSLStylesheet, doc, new PrintWriter(out));
    #sql { delete from wpg_document where name=:filename };
    } catch (SAXParseException spe) {
    throw new SQLException("processUpload SAXParseException: "+xmlError(spe));
    } catch (SAXException se) {
    throw new SQLException("processUpload SAXException: "+se.getLocalizedMessage());
    } catch (XSLException xsle) {
    throw new SQLException("processUpload XSLException: "+xsle.getLocalizedMessage());
    } finally {
    if (XSLStream!=null)
    XSLStream.close();
    if (theParser!=null)
    theParser = null;
    if (out!=null) {
    out.flush();
    out.close();
    zin.close();
    } catch (IOException ioe) {
    throw new SQLException("processUpload IOException: "+ioe.getLocalizedMessage());
    } finally {
    if (XSLStream!=null)
    XSLStream = null;
    if (out!=null)
    out = null;
    if (zin!=null)
    zin = null;
    Jxtp.redirecUrl("/dbprism/ldoc/live/edit.html?p_source="+toSource);
    Basically it takes the content from a BLOB column of the wpg_document table, unzip it using java.util.zip package, look for the file content.xml and parse it using Oracle XML toolkit.
    Using an open source utility which replace java.util.package (http://jazzlib.sourceforge.net/) it works perfect because is a pure java application.
    Best regards, Marcelo.
    PD: I am using Oracle 9.2.0.2 on Linux.

    The cause of errors was a dying Westen Digital drive, specially the 48G partition reserved only for $ORACLE_BASE (/dev/sdb3 mounted on /opt/oracle).
    A simple quick scan of unmounted partition (badblocks -v /dev/sdb3) reported more than thousand new bad blocks (compared to the last scan six months ago). Although I strongly believe, specially in the case of WDC drives, that the best utility to "repair" bad blocks is the one that opens a window and prints the message: "Go to the nearest shop and buy a new drive", I was very curious to prove my suspicion just on this drive. After zero-filling the partition with dd, then formatting it (mke2fs -cc) and mounting again, the 11g installation and database creation (on the same partition) successfully completed, performing fast and smoothly. To make sure it was not a casual event, I repeated the installation once again with full success. The database itself is working fine (by now). Well, the whole procedure took me more than four hours, but I'm pretty satisfied. I learned once again - stay away from Western Digital. As Oracle cannot rely on dying drive, my friend is going tomorrow to spend a 150+ euro on two 250G Seagate Barracudas and replace both WDC drives, even though the first drive seems to be healthy.
    In general there is no difference between loading correct data from good disk into bad memory and loading the incorrect data from dying disk into good memory. In both cases the pattern is damaged. For everyone who runs into the problem similar to this, and the cause cannot be easily determined, the rule of thumb must be:
    1. test memory and, if it shows any error, check sockets and test memory modules individually
    2. check disks for bad blocks regardless of the result of memory testing
    Therefore I consider your answer being generally correct.
    Regards
    NJ

  • Java.util.zip.ZIPException

    We are using Oracle Application Server 10g (10.1.2) with AIX OS version 5.3 release 6.
    We are getting error while deploying a "*.war" file. Below is the full error we have got during the installation.
    Error starting from below.
    Failed to deploy web application. File /tmp/dir1341.tmp/abc.war is not a jar file.
    Resolution :
    Base Exception:
    java.util.zip.ZIPException
    Error opening zip file /tmp/dir1341.tmp/abc.war
    Error opening zip file /tmp/dir1341.tmp/abc.war
    Kindly suggest the best provided solution for the same.
    Also let us know about the error belongs Oracle AS application?
    OR
    AIX OS Level error?

    Well as the error suggests, it is neither related to OracleAS nor AIX OS. It is complaining about the WAR file you are trying to deploy. Make sure your abc.war is a well formed WAR file. You can search google for tool to validate a war file.
    Thanks
    Shail

  • Java.util.zip.ZipException: invalid entry size error --  help required

    Hi all
    I am sure this error would have been posted many number of times, but I would really appreciate if someone could help me with my problem. I am working on reading data from a .zip file, which in it has ~5GB data. All I am performing is a read operation through the piece of code specified below. This code worked well for .zip files handling till ~2.5GB
    FileInputStream fis = new FileInputStream(filename);
    BufferedInputStream bis = new BufferedInputStream(fis);
    ZipInputStream zis = new ZipInputStream(bis);
    StreamTokenizer tok = new StreamTokenizer( zis );
    ZipEntry entry;
    while((entry = zis.getNextEntry()) != null)
    \\read from the zip file through the streamTokenizer
    I just print what I read through the program, on the console.
    But the error I get is
    java.util.zip.ZipException: invalid entry size (expected 4294967295 but got 2117536490 bytes)
    at java.util.zip.ZipInputStream.readEnd(Unknown Source)
    at java.util.zip.ZipInputStream.read(Unknown Source)
    at java.util.zip.InflaterInputStream.read(Unknown Source)
    at java.io.StreamTokenizer.read(Unknown Source)
    at java.io.StreamTokenizer.nextToken(Unknown Source)
    at ZipFileStreams.getMessages(ZipFileStreams.java:677)
    at ZipFileStreams.main(ZipFileStreams.java:814)
    Could anybody give me hints as to what am I missing and where am i going wrong. Any help would be appreciated.
    Thanks

    Hi,
    I get the same exception while reading a ZIP file. The size if the ZIP file is just 82KB but I am reading it over FTP not sure if it makes any difference. I am using JDK 1.4.2_05. Here is the code I am trying to execute.
    public class TestFTP {
    public static void main( String[] argv ) throws Exception {
    String inboundPath = "/transfer/inbound/";
    FTPClient ftp = new FTPClient();
    ftp.connect("123");
    ftp.login( "123", "123" );
    ftp.changeWorkingDirectory(inboundPath);
    FTPFile[] zipFiles = ftp.listFiles("*.zip");
    TelnetClient telnetClient;
    for(int i=0;i<zipFiles.length;i++){   
    System.out.println(zipFiles.getName());
    ZipInputStream zis = new ZipInputStream(ftp.retrieveFileStream(zipFiles[i].getName()));
    for (ZipEntry entry = zis.getNextEntry(); entry != null; entry = zis.getNextEntry()){           
    System.out.println(entry.getName());
    The error message is
    java.util.zip.ZipException: invalid entry size (expected 10291 but got 10233 bytes)
         at java.util.zip.ZipInputStream.readEnd(ZipInputStream.java:367)
         at java.util.zip.ZipInputStream.read(ZipInputStream.java:141)
         at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:91)
         at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:69)
         at test.TestFTP.main(TestFTP.java:41)
    Exception in thread "main"
    Please let me know if you were able to fix the problem.
    Thanks

  • Java.util.zip.ZipException Error

    I created a jar file, and put in C:\tools
    C:\tools>java -jar myjar.jar is working fine
    However, if I try to run myjar.jar in other directories, then I have problems.
    I already set the classpath:
    SET CLASSPATH=.;%CLASSPATH%;C:\tools\myjar.jar;
    Here's the error. Any ideas???
    C:\>java -jar myjar.jar
    Exception in thread "main" java.util.zip.ZipException: The system cannot find th
    e file specified
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:112)
    at java.util.jar.JarFile.<init>(JarFile.java:117)
    at java.util.jar.JarFile.<init>(JarFile.java:55)

    You always need to specify a proper file name when you use the -jar switch. If you are not in c:\tools you have to run with "java -jar c:\tools\myjar.jar".
    Setting the classpath in particular doesn't help becuase the file name given to the -jar switch will override all settings for classpath. http://java.sun.com/j2se/1.4/docs/tooldocs/findingclasses.html#userclass
    But since you now have myjar.jar in your classpath, you can run the application from any directory with "java your.main.ClassName" :)

  • Java.util.zip.DataFormatException: unknown compression method

    I'm trying to decompress data from an oralce database into a file, but I'm getting error. Any assistance would be greatly appreciated .
    package com.citi.blob;
    import java.sql.*;
    import java.io.*;
    import java.util.zip.Inflater;
    public class PullBlob {
         public static void main(String[] args) {
              // DB Connection info
              String userName="user";
              String passWord="password";
              //Production Database
              String dataBase="ABCD";
              //Production URL
              String url = "jdbc:oracle:thin:@111.2222.333.444:8080:" + dataBase;
              System.out.println("args length is" + args.length);
              // Sort out args
              if(args.length<2) {
                   System.out.println("Usage: java PullBLOB product acctnum optional-out-file");
                   System.exit(1);
              String product = args[0];
              String acctnum = args[1];
              String fileName = null;
              if(args.length>=3) {
                   fileName = args[2];
              Connection con = null;
              try {
                   // Establish connection
                   Class.forName("oracle.jdbc.driver.OracleDriver");
                   con = DriverManager.getConnection(url, userName, passWord);
                   Statement stmt = con.createStatement();
                   // Sort out the output stream
                   boolean toFile=false;
                   PrintWriter fout = null;
                   if(fileName!=null) {
                        File file = new File(fileName);
                        FileOutputStream fos = new FileOutputStream(file);
                        fout = new PrintWriter(fos);
                        toFile = true;
                   String query = "SELECT stm_cmp_xml FROM pld_stm WHERE prd_nm = 'JACKS_BOX' and act_num='9988556622'";
                   System.out.println(query);
                   ResultSet rs = stmt.executeQuery(query);
    //                      System.out.println("Number of records fetchted " + rs.getFetchSize());
                   if(rs.next()) {
                        //Blob xml = rs.getBlob("inv_cmp_xml");
                        Blob xml = rs.getBlob("stm_cmp_xml");
                        InputStream in = xml.getBinaryStream();
                        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
                        int data;
                        while ((data = in.read()) != -1) {
                             byteStream.write((byte)data);
                        byte[] compressedData = byteStream.toByteArray();
                        in.close();
                        Inflater decompressor = new Inflater();
                        decompressor.setInput(compressedData);
                        // Create an expandable byte array to hold the decompressed data
                        ByteArrayOutputStream bos = new ByteArrayOutputStream(compressedData.length);
                        // Decompress the data
                        //byte[] buf = new byte[TEMP_BUFFER_SIZE];
                        // use a 1 meg buffer for improved speed
                        byte [] buf = new byte[1048576];
                        while (!decompressor.finished()) {
                                  int count = decompressor.inflate(buf);
                                  bos.write(buf, 0, count);
                        buf=null;
                        bos.close();
                        //Get the decompressed data
                        byte[] decompressedData = bos.toByteArray();
                        String stmtXml = new String(decompressedData).trim();
                        if(toFile) {
                             fout.println(stmtXml);
                        else {
                             System.out.println(stmtXml);
                     else { // No result
                        System.out.println("Couldn't find stmt for " + acctnum );
                   if(fout!=null) fout.close();
              catch(Exception e) {
                   System.out.println(e.getMessage());
                   e.printStackTrace();
              finally {
                   try {
                        if(con!=null) con.close();
                   catch(Exception e) {
                        // Whatever
    }here is the output and error I receieve:
    args length is3
    SELECT stm_cmp_xml FROM pld_stm WHERE prd_nm = 'JACKS_BOX'  and act_num='9988556622'
    unknown compression method
    java.util.zip.DataFormatException: unknown compression method
         at java.util.zip.Inflater.inflateBytes(Native Method)
         at java.util.zip.Inflater.inflate(Unknown Source)
         at java.util.zip.Inflater.inflate(Unknown Source)
         at com.citi.blob.PullBlob.main(PullBlob.java:95)

    Take a look at class ZipFile.
    o Create one on your input.
    o Get an enumeration of the entries - the headers for your files within the zip file.
    o Ask for the input stream of the file you want.
    o Read the data - it is unzipped for you.

Maybe you are looking for

  • Howto learn 1Z0-051

    Hello, I want to learn the 1Z0-051, but how can I do that? I treid to install oracle 11gr2 on linux and windows, but I'va got a lot of errors. Is there an other way to learn the 1Z0-051? Is there a virtualbox image with everything I need? I hope some

  • Intel driver KMS and exa = black screen

    Hello, I just upgraded to xorg 1.6 today and have enabled KMS thanks to the howto thread in the fourms. Everything works great with UXA, It is when I try to enable EXA and try to startX I get a black screen and have to do a hard reboot. Does anyone e

  • Problem with currency

    Hi guys, i have this code below: write v_val curr v_curr to v_val_temp. write v_val_temp to v_price. im getting a dump that a " 8 000 000" can not be read as a number... v_val = 80000.00 (type curr) v_curr = KRW (type cuky) v_val_temp(13) (no type) v

  • RE: Appset Parameters Screen

    Hi All, I'm able to see the Appset parameters when I log onto the server where BPC is installed and when I tried accessing BPC with my developers User ID. But when the Developer is trying to access the Appset Parameters page from his machine with his

  • HT1689 how do i restore my iphone 5 from a previous backup in itunes

    I want to restore my iphone5 from a previous back up in itunes but when I plug my phone into my laptop and cancel the sync I can't find my phone? Help I'm new to itunes and iphone