Hi, ich habe mal diesen Code hier aus dem Internet gefischt, denn ich will alle in einer Zip Datei befindlichen Datei extrahieren.
Wenn ich dies aber versuche, klappts nicht warum?
Als String übergebe ich dem parameter "Paramecium".
Folgende Fehlermeldung:
Java:
@SuppressWarnings("unchecked")
public void extractZipFile(String s) throws Exception
{
String zipname = s+".zip";
ZipFile zipFile = new ZipFile(zipname);
Enumeration enumeration = zipFile.entries();
while (enumeration.hasMoreElements())
{
ZipEntry zipEntry = (ZipEntry) enumeration.nextElement();
System.out.println("Unzipping: " + zipEntry.getName());
BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(zipEntry));
int size;
byte[] buffer = new byte[2048];
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(zipEntry.getName()), buffer.length);
while ((size = bis.read(buffer, 0, buffer.length)) != -1)
{
bos.write(buffer, 0, size);
}
bos.flush();
bos.close();
bis.close();
}
}
Wenn ich dies aber versuche, klappts nicht warum?
Als String übergebe ich dem parameter "Paramecium".
Folgende Fehlermeldung:
Java:
Unzipping: Paramecium/Paramecium.jar
java.io.FileNotFoundException: Paramecium\Paramecium.jar (Das System kann den angegebenen Pfad nicht finden)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at Installer.Install.extractZipFile(Install.java:47)
at Installer.Install.<init>(Install.java:28)
at XAE.Data$1.mouseClicked(Data.java:46)
at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)