Zip file extraction errors

Hi, i'm not sure whether this is in the right forum, please feel free to move it if it's not appropriate here.
I'm trying to extract the contents of a .zip file and i'm getting the following exception:
java.io.FileNotFoundException: zip test\zip test.txt (The system cannot find the
path specified)
        at java.io.FileOutputStream.open(Native Method)
        at java.io.FileOutputStream.<init>(Unknown Source)
        at java.io.FileOutputStream.<init>(Unknown Source)
        at unzip3.main(unzip3.java:47)Here is the code i'm trying to run, it's a sample code I picked up off a tutorial. I've looked at a few tutorials and the code is more or less the same in all of them...
import java.io.*;
import java.util.*;
import java.util.zip.*;
public class unzip3 {
  public static final void copyInputStream(InputStream in, OutputStream out)
  throws IOException
    byte[] buffer = new byte[1024];
    int len;
    while((len = in.read(buffer)) >= 0)
      out.write(buffer, 0, len);
    in.close();
    out.close();
  public static final void main(String[] args) {
    Enumeration entries;
    ZipFile zipFile;
    if(args.length != 1) {
      System.err.println("Usage: Unzip zipfile");
      return;
    try {
      zipFile = new ZipFile(args[0]);
      entries = zipFile.entries();
      while(entries.hasMoreElements()) {
        ZipEntry entry = (ZipEntry)entries.nextElement();
        if(entry.isDirectory()) {
          // Assume directories are stored parents first then children.
          System.err.println("Extracting directory: " + entry.getName());
          // This is not robust, just for demonstration purposes.
          (new File(entry.getName())).mkdir();
          continue;
        System.err.println("Extracting file: " + entry.getName());
        copyInputStream(zipFile.getInputStream(entry),
           new BufferedOutputStream(new FileOutputStream(entry.getName())));
      zipFile.close();
    } catch (IOException ioe) {
      System.err.println("Unhandled exception:");
      ioe.printStackTrace();
      return;
}It doesn't seem to even be creating the directory for me.
Any help would be greatly appreciated!

What do you mean by adjusting my expectation?You expect the zip file to hand you back entries with "isDirectory" returning true, when it doesn't, as you have observed. So you have to change that expectation.
What do you suggest?For each entry you get, create a File object, invoke the getParentFile() method, and if that returns something (a File object representing the directory the target file belongs to), invoke its mkdirs() method to create the directory/directories the target file will belong to.
Experiment with it...

Similar Messages

  • Want ProgressBar During Zip File Extraction?

    i have develop a application
    ,in which zip file is extracted
    .(unzipping a zip file),but i want to show progressbar during zip file extract process,i have tried but i am unable to do that.........plz help me?here is my code.......
    ====================
    mxml file->
    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="initApp()">
    <mx:Script>
    <![CDATA[
    import com.kfc.repflex.utils.ZipExtractComponent;
    import mx.controls.Alert;
    [Bindable]
    private var zip:ZipExtractComponent = null;
    private function initApp():void{
    zip = new ZipExtractComponent("C:/AdobeAIRInstaller.zip");
    ]]>
    </mx:Script>
    <mx:Panel title="Load and extract ZIP files" layout="vertical" horizontalCenter="0" verticalCenter="0" horizontalAlign="center" verticalAlign="middle">
    <mx:Button id="load" label="Load and Extract ZIP" click="zip.loadZIP()"/>
    </mx:Panel>
    </mx:WindowedApplication>
    ====================================
    action script class->
    package com.amdocs.repflex.utils
    import com.amdocs.repflex.utils.zip.*;
    import flash.events.EventDispatcher;
    import flash.filesystem.*;
    import mx.controls.Alert;
    public class ZipExtractComponent extends EventDispatcher
    private var zipInput:File = new File();
    private var zipOutput:File = new File();
    private var zipFile:ZipFile=null;
    private var fileIn:String;
    private var fileOut:String;
    public function ZipExtractComponent(fIn:String){
    this.fileIn=fIn;
    //this.fileOut=fout;
    public function loadZIP():void
    zipInput.nativePath=fileIn;
    var stream:FileStream = new FileStream();
    stream.open(zipInput,FileMode.READ);
    zipFile = new ZipFile(stream);
    extractZip();
    public function extractZip():void
    for(var i:uint = 0; i<zipFile.entries.length; i++)
    var zipEntry:ZipEntry = zipFile.entries[i] as ZipEntry;
    if(!zipEntry.isDirectory())
    //zipOutput.nativePath=fileOut;
    //var targetDir:File = new File("C:/Documents and Settings");
    var targetDir:File = File.documentsDirectory.resolvePath("");
    var entryFile:File = new File();
    entryFile = targetDir.resolvePath(zipEntry.name);
    var entry:FileStream = new FileStream();
    entry.open(entryFile, FileMode.WRITE);
    entry.writeBytes(zipFile.getInput(zipEntry));
    entry.close();
    Alert.show("EXTRACTED SUCCESSFULLY");

    I'm running out of suggestions over here.
    Your exact command line yields this result:
    zip warning: name not matched: in.txt
    zip error: Nothing to do! (out.zip)
    Well, it should, as I don't have an in.txt. Handing it an existing file, I get this:
    zip -P pass out.zip result.txt
      adding: result.txt (deflated 7%)
    .. and opening in the Finder correctly prompts me:
    so there must be something wrong with your system.
    Very Long Shot: What version do you get when you type this? (I can't imagine this is the actual problem, but you never know.)
    zip --version
    Mine is
    Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
    This is Zip 3.0 (July 5th 2008), by Info-ZIP.
    Currently maintained by E. Gordon.  Please send bug reports to
    the authors using the web page at www.info-zip.org; see README for details.
    Latest sources and executables are at ftp://ftp.info-zip.org/pub/infozip,
    as of above date; see http://www.info-zip.org/ for other sites.
    Compiled with gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00) for Unix (Mac OS X) on May 25 2011.

  • Zip file exxtracting error of these two zip files

    Hi
    i download both zip files. when i click on these zip files, i receive a messeage that "NO ZIP FILE, BAD ZIP FILE OR PART OF A SPANNED/SPLIT ZIP FILE". When i try to extract it again show me error . Please guide me. when i download it , it download very smothly.
    Thanks
    Atiq

    please provide exact filesizes when you report such installation/unzip issues, also, you can compare the md5sum with the one posted on the website.
    sizes / name / md5sum:
    2055432139 RHEL3-DVD1-Oracle-v1.4.zip c571eec50edfd8c032e86cfacc7976cc
    812339260 RHEL3-DVD2-Linux-v1.4.zip 756444bc87871ed52eee9baeb1880390
    for md5sum on windows you can use: http://www.md5summer.com/
    on linux just type md5sum <filename>
    99.99% it's the download, based on the size/md5sum you'll know which zip you'll need to redownload.
    enjoy.

  • Zip file extraction fails

    After downloading the trial zip file several time: ie via wireless, ethernet, I've been unable to extract the zip file to began installation of the program. I've downloaded the beta file on 2 different windows7 computers and have unsuccessfully tried to extract the zip file. I receive an error message while attempting to extract the archive.
    Anyone have any thoughts on this?
    Regards,
    Wes

    Nope, it's a zip. All it contains is setup.exe, though.
    @a330,
    Is that the filename and size that you see on your download?
    Hal

  • Java.util.zip.ZipException: error in opening zip file Deploment Error

    Hi All,
    I am getting the fallowing Deployment exception while i am trying to deploy my webdynpro DC. Kindly help me if anybody know the solution for it.
    deployment aborted : file:/C:/DOCUME1/291123/LOCALS1/Temp/temp7081pg.comiprscipr~dc_intreg_process.ear
    Aborted: development component 'ipr/scipr/dc_intreg_process'/'pg.com'/'GGD_EPREGDEV_D'/'20101220152524'/'0':Caught exception during application deployment from SAP J2EE Engine's deploy service:java.rmi.RemoteException: Error while getting the internal libraries of application pg.com/iprsciprdc_intreg_process in operation update.. Reason: error in opening zip file; nested exception is:      java.util.zip.ZipException: error in opening zip file (message ID: com.sap.sdm.serverext.servertype.i
    Thanks,
    Mahesh Nuli.

    Hello Ram,
    It is saying that the library file is missing. Can you deploy pg.com/iprsciprdc_intreg_process  first and try to deploy this ear temp7081pg.comiprscipr~dc_intreg_process.ear.
    Regards
    Nizamudeen SM

  • Zip file attachment errors

    Hi,
    I have written a simple email client that sends a multipart message with a zip file attachment. I have written another email client that receives that email. I built it from looking at the javamail samples and the JGuru tutorial. Everything works fine on one mail host I am using, but I get errors on another email host. The two errors I see are....
    javax.mail.internet.ParseException
         at javax.mail.internet.ParameterList.<init>(ParameterList.java:61)
         at javax.mail.internet.ContentType.<init>(ContentType.java:83)
         at javax.mail.internet.MimeMultipart.parse(MimeMultipart.java:269)
         at javax.mail.internet.MimeMultipart.getCount(MimeMultipart.java:159)
    and...
    javax.mail.MessagingException: Missing start boundary
         at javax.mail.internet.MimeMultipart.parse(MimeMultipart.java:297)
         at javax.mail.internet.MimeMultipart.getCount(MimeMultipart.java:159)
    both of these errors occur when I call the MultiPart.getCount() method. I have seen a lot of similar posts here, but no solution. One hint at what my problem might be is that the host that I get the error on is in Europe. The most confusing thing is that other than having a different boundary, the received message that works correctly looks identical to the one that doesn't work.
    Any ideas on what the problem is?
    Thanks.

    Yes, I am having the same issue. But I am seeing these issue after the exchange server is upgraded to 2003. It seems like there is an issue with Message format in Exchange 2003. Any idea what we need to do fix this issue?

  • During file extraction, "Error during execution, error code =4"

    from Oracle® Fusion Middleware Getting Started With Installation for Oracle WebLogic Server
    11g Release 1 (10.3.1)
    http://download.oracle.com/docs/cd/E12839_01/web.1111/e13751/toc.htm#CIHCJJIA
    > said "instead of installing the JRockit JDK that is included, Oracle strongly recommends that you download and install the latest available JRockit version separately."
    selected "Oracle JRockit Mission Control 4.0, for Java version 6"
    > got file named: http://download.oracle.com/otn/bea/jrockit/jrmc-4.0.0-1.6.0-linux-ia32.bin
    Set permissions to *.bin installer:
    chmod a+x file_name.bin ./file_name.bin
    During file extraction (as 'oracle' user/owner) got: "Error during execution, error code =4"
    Please advise.
    thank you.

    hi,
    i ran into teh same problem and just figured out that my CPU is too old (AMD Athlon 3000+). This processor doesnt support SSE2, as required, see
    http://download.oracle.com/docs/cd/E15289_01/doc.40/e15066/suppconfigchanges.htm#CHDDFHJF
    does your machine have all the relevant features?

  • File Extraction Error during Adobe Acrobat XI Pro installation

    I continually no matter how many times I re-download Adobe Acrobat XI Pro Student and Teacher Edition, I receive the same error "Error in extracting files. Re-download Adobe Acrobat XI Pro." (Paraphrased).  Suggestions?

    This was my goofup... please be sure to type subst and not substr Z: "C:\Windows" in the command prompt for Admin.
    The source I copied and pasted from added the "r"
    With the proper command adjusting the "invalid" drive, the install of acrobat succeeded.

  • Adobe CS5 Master Collection downloaded files extraction error

    Every time I download Adobe CS5 Master Collection, it give me this error, "A problem occued while extracting some files. Check available space on your computer and the write privileges on the destinition folder". I've 16.3GB free space in the drive in which I'm extacting this file and I'm logged in as Administrator.. I'm fadup of this... goosh its 4.45 GB.. Please help..

    where are you extracting the file?
    if you are extracting the file to program files try to change the path like c:\installer

  • Business object edge 3.1 trial version- File extraction error in Part 3

    Hi,
    I am getting an error message while extrcting pat3 BO edge 3.1 trial version.
    Error: 'CRC failed in collaterals\Client installer\Package\langs\th\BussinessObjectsClient_th.msi The file is corrupt.
    'Unexpected end of archive'
    I tried to download and extract 3 times from http://www.businessobjects.com/campaigns/forms/downloads/edge/smallbusiness/
    but getting same error message.
    Could anyone help me so that i can start using BO trial version.
    Regards,
    Avinder Singh
    PUNE

    You may need to disable firewall on your desktop and try by passing the firewall on the network. They are liking blocking some content within the Archive file.

  • Errors in ZIP files from OTN

    Hello,
    I try to download the client software for Oracle 8.1.7 on NT, but the downloaded ZIP file contains errors. When I try to fix the errors my original ZIP file is truncated from over 500Mb to 20Kb! And it does not work of course.
    All the other ZIP files contains errors too.
    I use the PKWARE PKunzip utility.
    Where can I find the correct ZIP files for download?
    Kind regards, Richard Klavers.

    Can you please try with this direct url: http://otn.oracle.com/software/htdocs/devlic.html?http://download.oracle.com/otn/nt/oracle8i/win817client.zip
    Regards,
    OTN

  • Calendar portlet - bad zip file

    Please replace the zip file for the calendar portlet. CRC error - premature end of file reached.
    Thanks.

    Sue,
    I've downloaded the Calendar portlet - June PDK. I am using WinZip 8.0
    The zip file opens, however when extracting the contents I get:
    "Error in file #1: bad Zip file offset(Error local header signature not found): disk #1 offset:97."
    "Error in file #2: bad Zip file offset(Error local header signature not found): disk #2 offset:567." ... and it shows missing header signatures for the rest of the files. I've just downloaded the calendar portlet again (12:45PM EST) and I get the same message. I have tried that on 5 different computers and I get the same message. The test shows that the archive is OK, but when you attempt to extract the files you get the error messages above.
    --George
    P.S. I've tried extracting the files with WinAce and WinRar and I get the same errors.

  • Java Plug-in 1.4.0 throws an IllegalStateException: zip file closed

    Cross-posting to reach a wider audience:
    Java Plug-in 1.4.0 throws an IllegalStateException: zip file closed
    Author: remyb Jul 23, 2002 6:36 AM
    A IllegalStateException is thrown when the class loader
    try to load a class from my applet JAR file.
    The applet is embedded in a JSP page which use the Plug-In 1.4.0.
    That JSP is hosted by Tomcat 4.0.1.
    The applet JAR file is signed with a self-signed certificate.
    The applet has been compiled with JDK 1.4.0.
    The jar has been put in the Plug-in cache successfully.
    Here is the stack trace I got in the Java Console ...
    java.lang.IllegalStateException: zip file closed
    at java.util.zip.ZipFile.getEntry(Unknown Source)
    at java.util.jar.JarFile.getEntry(Unknown Source)
    at sun.plugin.cache.CachedJarFile.getEntry(Unknown Source)
    at java.util.jar.JarFile.getJarEntry(Unknown Source)
    at sun.misc.URLClassPath$JarLoader.getResource(Unknown Source)
    at sun.misc.URLClassPath.getResource(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at sun.applet.AppletClassLoader.findClass(Unknown Source)
    at sun.plugin.security.PluginClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Please somebody help me !!
    Thanks !
    Re: Java Plug-in 1.4.0 throws an IllegalStateException: zip file closed
    Author: mutmansky
    In Reply To: Java Plug-in 1.4.0 throws an IllegalStateException: zip file closed Jul 26, 2002 6:36 AM
    Reply 1 of 1
    I've got a very similar error, but unfortuneatly I don't have an answer yet. The only difference is that my Applet is embedded in a standard HTML page, and loaded via Apache. Once the Applet runs, it then communicates with the servlet via Tomcat. I also exchange data with another server task via CORBA.
    But everything else is the same, self-signed applet, applet compiles successfully, and jar is being put in the Plug-in Caceh successfully.
    I have narrowed the problem down a bit, and maybe you can tell me if you're in a similar situation:
    In my case, I need to encrypt the data that I'm sending through CORBA, so I create a Cipher object using Cipher.getInstance(). This method call seems to be the catalyst of my troubles. No matter where I move that call in my code, the next time the code tries to instantiate a class defined in my applet jar file after that "getInstance" call, I get the "zip file closed error." It's like the classloader is confused, because the Cipher.getInstance method would be accessing a different jar file or something. Are you trying to do something similar? Maybe not creating a Cipher, but creating some other object defined outside your own jar-file?
    To top it off, if I disable caching in the Plugin control panel, everything works fine. But that's not really an option for me, since it slows things down a lot, and I can't make all my users go into their control panels and disable caching. But at leasts it makes me confident that there's not a problem with my code.
    In my latest attempt to circumvent this problem, I even put the Cipher.getInstance() call in a static initializer. Here's the stack trace from that attempt:
    java.lang.IllegalStateException: zip file closed
    at java.util.zip.ZipFile.getEntry(Unknown Source)
    at java.util.jar.JarFile.getEntry(Unknown Source)
    at sun.plugin.cache.CachedJarFile.getEntry(Unknown Source)
    at java.util.jar.JarFile.getJarEntry(Unknown Source)
    at sun.misc.URLClassPath$JarLoader.getResource(Unknown Source)
    at sun.misc.URLClassPath.getResource(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at sun.applet.AppletClassLoader.findClass(Unknown Source)
    at sun.plugin.security.PluginClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at com.uss.wbi.client.WBIClient.<init>(WBIClient.java:404)
    at com.uss.wbi.client.WBIApplet.init(WBIApplet.java:122)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    In other words, since the getInstance method is in a static initializer, the next thing to run is the applet.init(), which is what is failing now. If I move the Cipher.getInstance method into the client constructor, the next time I instantiate a new object, I'll get the error there.
    Has anybody else seen anything like this? Or does anybody know how I can flush the Cache from the applet code? Or can I reset the ClassLoader in some way in the code?
    Thanks,
    Steve

    Well, I finally came to a solution that is acceptable at least to me, if not ideal. I've started using the BouncyCastle lightweight API. This makes my code somewhat more complicated, and I had to bundle up all the BouncyCastle classes that I'm using into a jar file, and download that to my applet along with my client jar file (after signing the jar files). Using this Lightweight API bypasses the Cipher.getInstance() method all together, and is a little harder to use, but at least everything is working consistently now.
    I still believe this to be a bug either in the ClassLoader or the Cipher.getInstance() method. I intend to try to write a test applet that reproduces the error in a more simple way and if I can pull that off, I'll submit a bug report to Sun.
    Thanks to all who responded!!
    Steve

  • I cannot open mp3 files I received from a purchased download. They are in a .zip file but no matter what I do, they cannot be opened. Please help.

    I have right clicked and selected open, and the loading ring shows but nothing happens. I have also extracted the files, opened them in itunes and windows media player. (cannot be accesed in itunes or wmp)

    With ZIP files, extract was your best bet. Do the players report that the file is corrupted, or zero length?? You may need to check with the seller on whether the ZIPs downloaded correctly or see whether you can get another format.
    You also could try downloading again using Internet Explorer, if they allow that.

  • Can't Open Zip files

    Everytime it fails. I can't open zip files. Does anyone know why. I have my settings to allow all files when downloading something. When I go to download and it is complete it gives a setup exe. then I click on it and it does nothing.....
    Plesae help...Starting to drive me nuts!

    Hi Booher,
    Zip files are cross platform. Doesn't matter if it's an a PC or a Mac. Either can open or create them. But .exe files are Windows only. An .exe is an application compiled for MS DOS or Windows, as are .com files. They won't work at all on a Mac without running them in a Windows environment such as Virtual PC.
    The only exception is if the .exe is a self extracting archive created on a PC. That is, a .zip file converted to an .exe so if the person the compressed files are sent to doesn't have a way to open a .zip file, it will run as a program to do the same thing. These, OS X can open and extract as if it were still a .zip file.
    You mention that one of the .zip files extracted its contents as a file named setup.exe. This will not work directly in the Mac OS in any way, as it is a Windows application/program.

Maybe you are looking for

  • MR11 log file

    Hi, While run MR11 for GR/IR clearing account a log file is generated and document number is 5400000010. Where this log file is stored by default and how it should display ? Beside F.13 automatic clearing  clears those GR/IR records whose balance sho

  • Epossuplgateway.exe keeps going online

    I have the Nokia C5-03, and am having the same problem as this: http://betalabs.nokia.com/apps/ovi-maps-for-mobile-v3-06/bugreport/14627/epossuplgateway-exe-launche... Basically, an application by the name of epossuplgateway.exe keeps connecting to

  • E71x Mail for Exchange search or find

    Hello, I just moved from a Windows Mobile device to the e71x and can't seem to figure out how to search for or find an e-mail within Mail for Exchange. Is this even possible? If not, are there 3rd. party apps that would let me?

  • Spool not generated in RSNAST00 program

    Hi, My requirement is I have certain RMA numbers in internal table and I have to submit RSNAST00 program in background to process all these numbers. I have done that but I am not able to see the generated spool in sp01 transaction. I can see the fini

  • Lightroom 5 issue. error occurred when attempting to change modules

    I installed lightroom 5.7.1 and an error appears " error occurred when attempting to change modules. And Lightroom does not work