mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-06 18:45:09 +00:00
#798 close file streams after export
This commit is contained in:
@@ -1815,7 +1815,9 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
@Override
|
||||
public void run() throws IOException {
|
||||
File f = new File(foutdir + File.separator + (fframes.get(fi) + 1) + ".png");
|
||||
ImageHelper.write(frameImages.next(), "PNG", new FileOutputStream(f));
|
||||
try (FileOutputStream fos = new FileOutputStream(f)) {
|
||||
ImageHelper.write(frameImages.next(), "PNG", fos);
|
||||
}
|
||||
ret.add(f);
|
||||
}
|
||||
}, handler).run();
|
||||
|
||||
@@ -2350,7 +2350,9 @@ public class ActionScriptParser {
|
||||
ABC abc = new ABC(swf);
|
||||
ActionScriptParser parser = new ActionScriptParser(abc, playerABCs);
|
||||
parser.addScript(new String(Helper.readFile(src), "UTF-8"), true, src, classPos);
|
||||
abc.saveToStream(new FileOutputStream(new File(dst)));
|
||||
try (FileOutputStream fos = new FileOutputStream(new File(dst))) {
|
||||
abc.saveToStream(fos);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(ActionScriptParser.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
|
||||
import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler;
|
||||
@@ -77,7 +78,9 @@ public class ImageExporter {
|
||||
if (ffileFormat.equals("bmp")) {
|
||||
BMPFile.saveBitmap(imageTag.getImage().getBufferedImage(), file);
|
||||
} else {
|
||||
} else {
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
ImageHelper.write(imageTag.getImage().getBufferedImage(), ffileFormat.toUpperCase(Locale.ENGLISH), fos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, handler).run();
|
||||
|
||||
@@ -114,7 +114,9 @@ public class ShapeExporter {
|
||||
m.scale(settings.zoom);
|
||||
st.toImage(0, 0, 0, new RenderContext(), img, m, new CXFORMWITHALPHA());
|
||||
if (settings.mode == ShapeExportMode.PNG) {
|
||||
ImageHelper.write(img.getBufferedImage(), "PNG", new FileOutputStream(file));
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
ImageHelper.write(img.getBufferedImage(), "PNG", fos);
|
||||
}
|
||||
} else {
|
||||
BMPFile.saveBitmap(img.getBufferedImage(), file);
|
||||
}
|
||||
|
||||
@@ -85,15 +85,9 @@ public class BMPFile extends Component {
|
||||
|
||||
public static void saveBitmap(Image image, File file) throws IOException {
|
||||
BMPFile b = new BMPFile();
|
||||
b.fo = new FileOutputStream(file);
|
||||
try {
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
b.fo = fos;
|
||||
b.save(image, image.getWidth(null), image.getHeight(null));
|
||||
} finally {
|
||||
try {
|
||||
b.fo.close();
|
||||
} catch (Exception ex) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user