Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FileNotFoundException when extracting dir from zip/jar

62 views
Skip to first unread message

Petterson Mikael

unread,
Jun 14, 2005, 9:15:21 AM6/14/05
to
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

unread,
Jun 14, 2005, 9:30:16 AM6/14/05
to
On Tue, 14 Jun 2005 15:15:21 +0200, Petterson Mikael wrote:

> 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. )

--
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

0 new messages