Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / June 2005

Tip: Looking for answers? Try searching our database.

FileNotFoundException when extracting dir from zip/jar

Thread view: 
Petterson Mikael - 14 Jun 2005 14:15 GMT
Hi,

I am trying to extract a jar/zip file but have problems when it comes to
directories.

I get the following error:

unzipping markfile
Directory is META-INF/
unzipping META-INF/MANIFEST.MF
java.io.FileNotFoundException: META-INF/MANIFEST.MF (Not a directory)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
    at
se.ericsson.wcdma.rbs.tool.bdediff.resource.RepackJar.unzip(RepackJar.java:126)
    at
se.ericsson.wcdma.rbs.tool.bdediff.resource.RepackJar.ManyToOne(RepackJar.java:54)
    at
se.ericsson.wcdma.rbs.tool.bdediff.resource.JarClassLoader$Main.main(JarClassLoader.java:135)

Is there anyone who can tell me why it is not stable and what I can do
about it?

Cheers,

//mikael

This is the class that I am using:
==================================

package se.ericsson.wcdma.rbs.tool.bdediff.resource;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Hashtable;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class RepackJar {

    private boolean debugOn = true;

    private Hashtable htSizes = new Hashtable();

    public RepackJar() {

    }

    public void ManyToOne(String[] jars, String path) {
        // unpack all jars
        for (int i = 0; i < jars.length; i++) {
            String inFilename = path.concat(File.separator + jars[i]);
            if (debugOn) {
                System.out.println("---> " + inFilename);
            }
            try {
                InputStream in = new BufferedInputStream(new FileInputStream(
                        inFilename));
                ZipInputStream zin = new ZipInputStream(in);
                ZipEntry e;

                while ((e = zin.getNextEntry()) != null) {
                    if (e.isDirectory()) {
                        System.out.println("Directory is " + e.getName());
                        new File(e.getName()).mkdir();
                    }
                    if (e.getName().equals(inFilename)) {
                        unzip(zin, inFilename);
                        break;
                    }

                    unzip(zin, e.getName());
                }
                zin.close();
            } catch (FileNotFoundException fnfe) {
                fnfe.printStackTrace();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
        }

    }

    public void unzip(ZipInputStream zin, String s) throws IOException {
        System.out.println("unzipping " + s);
        FileOutputStream out = new FileOutputStream(s);
        byte[] b = new byte[512];
        int len = 0;
        while ((len = zin.read(b)) != -1) {
            out.write(b, 0, len);
        }
        out.close();
    }

}
Andrew Thompson - 14 Jun 2005 14:30 GMT
> This is the class that I am using:
> ==================================

Why not post an SSCCE?  
<http://www.physci.org/codes/sscce.jsp>

( And please replace each tab with a couple of spaces before
posting code to usenet. )

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.