Hi, ich brauche dringend Hilfe! Und zwar lese ich viele logfiles ein und tu die Informationen in eine datenbank eintragen. Beim entpacken sind aber zwei Arten von Dateien drinnen, einaml mit der Endung ".log" und mit ".ut".
Ich brauche die Dateien mit der Endung ".log". Die Informationen bekomme ich auch daraus. Da die Schleife jetzt aber auch versucht, die .ut datei zu lesen bekommen ich einen Fehler. Wie kann ich die ut-files überspringen, weil in denen kein Informationen vorhanden ist brauch ich die nicht.
Die Fehlermeldung:
java.io.IOException: Stream closed
at java.util.zip.ZipInputStream.ensureOpen(Unknown Source)
at java.util.zip.ZipInputStream.getNextEntry(Unknown Source)
at verschieben.Dateien.getNextZipFiles(Dateien.java:387)
at verschieben.Dateien.getZipFiles(Dateien.java:263)
at verschieben.Dateien.copyFolder(Dateien.java:96)
at verschieben.GUI$4.actionPerformed(GUI.java:159)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(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.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(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)
Ich brauche die Dateien mit der Endung ".log". Die Informationen bekomme ich auch daraus. Da die Schleife jetzt aber auch versucht, die .ut datei zu lesen bekommen ich einen Fehler. Wie kann ich die ut-files überspringen, weil in denen kein Informationen vorhanden ist brauch ich die nicht.
Die Fehlermeldung:
java.io.IOException: Stream closed
at java.util.zip.ZipInputStream.ensureOpen(Unknown Source)
at java.util.zip.ZipInputStream.getNextEntry(Unknown Source)
at verschieben.Dateien.getNextZipFiles(Dateien.java:387)
at verschieben.Dateien.getZipFiles(Dateien.java:263)
at verschieben.Dateien.copyFolder(Dateien.java:96)
at verschieben.GUI$4.actionPerformed(GUI.java:159)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(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.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(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)
Java:
public void getNextZipFiles(File ext) {
if (gui.c.getSelectedItem().equals("XD")) {
try {
String neu = "XD";
File tmpfolder = new File(neu);
if (!tmpfolder.exists()) {
tmpfolder.mkdirs();
}
byte[] buf = new byte[1024];
ZipInputStream zipIn = null;
ZipEntry zipentry;
zipIn = new ZipInputStream(new FileInputStream(ext));
zipentry = zipIn.getNextEntry();
while (zipentry != null) {
String entryName = zipentry.getName();
System.out.println("Name of the XML-Data: " + entryName);
int n;
FileOutputStream fileoutputstream;
File newFile = new File(entryName);
String directory = newFile.getParent();
db.update2(entryName, ext.getName());
if (directory == null) {
if (newFile.isDirectory())
break;
}
fileoutputstream = new FileOutputStream(neu + "/" + entryName);
while ((n = zipIn.read(buf, 0, 1024)) > -1)
fileoutputstream.write(buf, 0, n);
fileoutputstream.close();
zipIn.closeEntry();
zipentry = zipIn.getNextEntry();
zipIn.close();
String files[] = tmpfolder.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".xml") || name.endsWith(".log");
}
});
for (String file : files) {
File input2 = new File(tmpfolder, file);
XML(input2);
input2.delete();
}
// }
// }
}
} catch (Exception e) {
e.printStackTrace();
}
} else if (gui.c.getSelectedItem().equals("DAS")) {
try {
String neu1 = "DAS";
File tmpfolder1 = new File(neu1);
if (!tmpfolder1.exists()) {
tmpfolder1.mkdirs();
}
byte[] buf = new byte[1024];
ZipInputStream zipIn = null;
ZipEntry zipentry;
zipIn = new ZipInputStream(new FileInputStream(ext));
zipentry = zipIn.getNextEntry();
while (zipentry != null) {
String entryName = zipentry.getName();
System.out.println("Name of the XML-Data: " + entryName);
int n;
FileOutputStream fileoutputstream;
File newFile = new File(entryName);
String directory = newFile.getParent();
if(entryName.endsWith(".log")){
db.update2(entryName, ext.getName());
if (directory == null) {
if (newFile.isDirectory())
break;
}
fileoutputstream = new FileOutputStream(neu1 + "/" + entryName);
while ((n = zipIn.read(buf, 0, 1024)) > -1)
fileoutputstream.write(buf, 0, n);
fileoutputstream.close();
zipIn.closeEntry();
zipentry = zipIn.getNextEntry();
zipIn.close();
String files[] = tmpfolder1.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".xml") || name.endsWith(".log") || name.endsWith(".ut");
}
});
for (String file : files) {
File input2 = new File(tmpfolder1, file);
XML(input2);
input2.delete();
}
}else{
ext.delete();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}