From 5024093c54273f59a915ebd33a7c493db24d7169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Tue, 16 Aug 2016 20:44:43 +0200 Subject: [PATCH] SwcExporter file close fix --- .../flash/exporters/swf/SwfToSwcExporter.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfToSwcExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfToSwcExporter.java index 039748896..69fed58d3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfToSwcExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfToSwcExporter.java @@ -235,8 +235,11 @@ public class SwfToSwcExporter { String catalogStr = generateCatalog(swf, swfBytes, skipDependencies); File tempFile = new File((outSwcFile.getAbsolutePath()) + ".tmp"); - try (FileOutputStream fos = new FileOutputStream(tempFile); - ZipOutputStream zos = new ZipOutputStream(fos)) { + FileOutputStream fos = null; + ZipOutputStream zos = null; + try { + fos = new FileOutputStream(tempFile); + zos = new ZipOutputStream(fos); ZipEntry libraryEntry = new ZipEntry("library.swf"); zos.putNextEntry(libraryEntry); @@ -249,9 +252,27 @@ public class SwfToSwcExporter { zos.closeEntry(); zos.close(); + zos = null; + fos.close(); + fos = null; outSwcFile.delete(); tempFile.renameTo(outSwcFile); } finally { + if (zos != null) { + try { + zos.close(); + } catch (IOException ex) { + //ignore + } + + } + if (fos != null) { + try { + fos.close(); + } catch (IOException ex) { + //ignore + } + } if (tempFile.exists()) { tempFile.delete(); }