diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java index ef6a79a69..1e2e222aa 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java @@ -106,10 +106,12 @@ import com.jpexs.decompiler.graph.model.TernarOpItem; import com.jpexs.decompiler.graph.model.UnboundedTypeItem; import com.jpexs.decompiler.graph.model.WhileItem; import com.jpexs.helpers.Helper; +import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -2429,7 +2431,7 @@ public class ActionScriptParser { ABC abc = new ABC(null); ActionScriptParser parser = new ActionScriptParser(abc, playerABCs); parser.addScript(new String(Helper.readFile(src), "UTF-8"), true, src, classPos); - try (FileOutputStream fos = new FileOutputStream(new File(dst))) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(new File(dst)))) { abc.saveToStream(fos); } } catch (Exception ex) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/BinaryDataExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/BinaryDataExporter.java index 4046acdee..8b71b47b9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/BinaryDataExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/BinaryDataExporter.java @@ -24,9 +24,11 @@ import com.jpexs.decompiler.flash.exporters.settings.BinaryDataExportSettings; import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.helpers.Path; +import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.util.ArrayList; import java.util.List; @@ -69,7 +71,7 @@ public class BinaryDataExporter { new RetryTask(new RunnableIOEx() { @Override public void run() throws IOException { - try (FileOutputStream fos = new FileOutputStream(file)) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { fos.write(((DefineBinaryDataTag) t).binaryData.getRangeData()); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java index 172d6d71c..747e1b5ae 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java @@ -39,10 +39,12 @@ import com.jpexs.helpers.Path; import fontastic.FGlyph; import fontastic.FPoint; import fontastic.Fontastic; +import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -279,7 +281,7 @@ public class FontExporter { Font font = fontArray[0]; - try (FileOutputStream fos = new FileOutputStream(file)) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { WoffWriter w = new WoffWriter(); WritableFontData woffData = w.convert(font); woffData.copyTo(fos); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FrameExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FrameExporter.java index 5dde7f0ae..0d61f104a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FrameExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FrameExporter.java @@ -61,10 +61,12 @@ import java.awt.Graphics; import java.awt.image.BufferedImage; import java.awt.print.PageFormat; import java.awt.print.Paper; +import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; @@ -160,7 +162,7 @@ public class FrameExporter { public void run() throws IOException { int frame = fframes.get(fi); File f = new File(foutdir + File.separator + frame + ".svg"); - try (FileOutputStream fos = new FileOutputStream(f)) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(f))) { ExportRectangle rect = new ExportRectangle(tim.displayRect); rect.xMax *= settings.zoom; rect.yMax *= settings.zoom; @@ -204,7 +206,7 @@ public class FrameExporter { File fmin = new File(foutdir + File.separator + "frames.min.js"); int width = (int) (ftim.displayRect.getWidth() * settings.zoom / SWF.unitDivisor); int height = (int) (ftim.displayRect.getHeight() * settings.zoom / SWF.unitDivisor); - try (FileOutputStream fos = new FileOutputStream(f)) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(f))) { fos.write(Utf8Helper.getBytes("\r\n")); Set library = new HashSet<>(); ftim.getNeededCharacters(fframes, library); @@ -274,7 +276,7 @@ public class FrameExporter { } File fh = new File(foutdir + File.separator + "frames.html"); - try (FileOutputStream fos = new FileOutputStream(fh); FileInputStream fis = new FileInputStream(fmin)) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(fh)); FileInputStream fis = new FileInputStream(fmin)) { fos.write(Utf8Helper.getBytes(CanvasShapeExporter.getHtmlPrefix(width, height))); fos.write(Utf8Helper.getBytes(CanvasShapeExporter.getJsPrefix())); byte[] buf = new byte[1000]; @@ -380,7 +382,7 @@ public class FrameExporter { @Override public void run() throws IOException { File f = new File(foutdir + File.separator + "frames.pdf"); - PDFJob job = new PDFJob(new FileOutputStream(f)); + PDFJob job = new PDFJob(new BufferedOutputStream(new FileOutputStream(f))); PageFormat pf = new PageFormat(); pf.setOrientation(PageFormat.PORTRAIT); Paper p = new Paper(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java index 9fb3a80c0..e8833db5d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java @@ -34,10 +34,12 @@ import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; import com.jpexs.helpers.Helper; import com.jpexs.helpers.Path; import com.jpexs.helpers.utf8.Utf8Helper; +import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -90,7 +92,7 @@ public class MorphShapeExporter { MorphShapeTag mst = (MorphShapeTag) t; switch (settings.mode) { case SVG: - try (FileOutputStream fos = new FileOutputStream(file)) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { ExportRectangle rect = new ExportRectangle(mst.getRect()); rect.xMax *= settings.zoom; rect.yMax *= settings.zoom; @@ -102,7 +104,7 @@ public class MorphShapeExporter { } break; case CANVAS: - try (FileOutputStream fos = new FileOutputStream(file)) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { int deltaX = -Math.min(mst.getStartBounds().Xmin, mst.getEndBounds().Xmin); int deltaY = -Math.min(mst.getStartBounds().Ymin, mst.getEndBounds().Ymin); CanvasMorphShapeExporter cse = new CanvasMorphShapeExporter(((Tag) mst).getSwf(), mst.getShapeAtRatio(0), mst.getShapeAtRatio(DefineMorphShapeTag.MAX_RATIO), new CXFORMWITHALPHA(), SWF.unitDivisor, deltaX, deltaY); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MovieExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MovieExporter.java index 2d183eb32..3a6476f39 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MovieExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MovieExporter.java @@ -33,6 +33,7 @@ import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.VideoFrameTag; import com.jpexs.helpers.Helper; import com.jpexs.helpers.Path; +import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; @@ -80,7 +81,7 @@ public class MovieExporter { new RetryTask(new RunnableIOEx() { @Override public void run() throws IOException { - try (FileOutputStream fos = new FileOutputStream(file)) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { fos.write(exportMovie(videoStream, settings.mode)); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java index ba9d5ee30..db48fa930 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java @@ -40,10 +40,12 @@ import com.jpexs.helpers.Helper; import com.jpexs.helpers.Path; import com.jpexs.helpers.SerializableImage; import com.jpexs.helpers.utf8.Utf8Helper; +import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -104,7 +106,7 @@ public class ShapeExporter { ShapeTag st = (ShapeTag) t; switch (settings.mode) { case SVG: - try (FileOutputStream fos = new FileOutputStream(file)) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { ExportRectangle rect = new ExportRectangle(st.getRect()); rect.xMax *= settings.zoom; rect.yMax *= settings.zoom; @@ -133,7 +135,7 @@ public class ShapeExporter { } break; case CANVAS: - try (FileOutputStream fos = new FileOutputStream(file)) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { SHAPE shp = st.getShapes(); int deltaX = -shp.getBounds().Xmin; int deltaY = -shp.getBounds().Ymin; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/TextExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/TextExporter.java index e74fb0a50..87b64de62 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/TextExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/TextExporter.java @@ -31,9 +31,11 @@ import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; import com.jpexs.helpers.Helper; import com.jpexs.helpers.Path; import com.jpexs.helpers.utf8.Utf8Helper; +import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.util.ArrayList; import java.util.List; @@ -80,7 +82,7 @@ public class TextExporter { new RetryTask(new RunnableIOEx() { @Override public void run() throws IOException { - try (FileOutputStream fos = new FileOutputStream(file)) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { ExportRectangle rect = new ExportRectangle(textTag.getRect()); SVGExporter exporter = new SVGExporter(rect); textTag.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0, settings.zoom); @@ -109,7 +111,7 @@ public class TextExporter { fileName = settings.mode == TextExportMode.FORMATTED ? TEXT_EXPORT_FILENAME_FORMATTED : TEXT_EXPORT_FILENAME_PLAIN; } final File file = new File(outdir + File.separator + fileName); - try (FileOutputStream fos = new FileOutputStream(file)) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { for (final Tag t : tags) { if (t instanceof TextTag) { final TextTag textTag = (TextTag) t; @@ -144,7 +146,7 @@ public class TextExporter { new RetryTask(new RunnableIOEx() { @Override public void run() throws IOException { - try (FileOutputStream fos = new FileOutputStream(file)) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { if (settings.mode == TextExportMode.FORMATTED) { fos.write(Utf8Helper.getBytes(textTag.getFormattedText().text)); } else { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfXmlExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfXmlExporter.java index 6d95728ac..a7dddcbcf 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfXmlExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfXmlExporter.java @@ -24,8 +24,9 @@ import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.helpers.ByteArrayRange; import com.jpexs.helpers.Helper; import com.jpexs.helpers.ReflectionTools; +import com.jpexs.helpers.Stopwatch; import com.jpexs.helpers.utf8.Utf8OutputStreamWriter; -import java.io.BufferedWriter; +import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -35,7 +36,9 @@ import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import javax.xml.parsers.DocumentBuilder; @@ -57,15 +60,21 @@ import org.w3c.dom.Node; */ public class SwfXmlExporter { + private Map> cachedFields = new HashMap<>(); + public List exportXml(SWF swf, File outFile) throws IOException { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); try { + Stopwatch sw = Stopwatch.startNew(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document xmlDoc = docBuilder.newDocument(); exportXml(swf, xmlDoc, xmlDoc); - try (Writer writer = new BufferedWriter(new Utf8OutputStreamWriter(new FileOutputStream(outFile)))) { + System.out.println(sw.getElapsedMilliseconds()); + try (Writer writer = new Utf8OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(outFile)))) { writer.append(getXml(xmlDoc)); } + sw.stop(); + System.out.println(sw.getElapsedMilliseconds()); } catch (ParserConfigurationException ex) { Logger.getLogger(SwfXmlExporter.class.getName()).log(Level.SEVERE, null, ex); } @@ -104,7 +113,17 @@ public class SwfXmlExporter { return sb.toString(); } - private static void generateXml(Document doc, Node node, String name, Object obj, boolean isListItem, int level) { + public List getSwfFieldsCached(Class cls) { + List result = cachedFields.get(cls); + if (result == null) { + result = ReflectionTools.getSwfFields(cls); + cachedFields.put(cls, result); + } + + return result; + } + + private void generateXml(Document doc, Node node, String name, Object obj, boolean isListItem, int level) { Class cls = obj != null ? obj.getClass() : null; if (cls == Byte.class || cls == byte.class @@ -163,7 +182,7 @@ public class SwfXmlExporter { } String className = clazz.getSimpleName(); - List fields = ReflectionTools.getSwfFields(obj.getClass()); + List fields = getSwfFieldsCached(obj.getClass()); Element objNode = doc.createElement(name); objNode.setAttribute("type", className); node.appendChild(objNode); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/BMPFile.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/BMPFile.java index 24000ea88..6eb5adc0c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/BMPFile.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/BMPFile.java @@ -19,9 +19,11 @@ package com.jpexs.decompiler.flash.helpers; import java.awt.Component; import java.awt.Image; import java.awt.image.PixelGrabber; +import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; /** * Adapted from @@ -77,7 +79,7 @@ public class BMPFile extends Component { private int[] bitmap; //--- File section - private FileOutputStream fo; + private OutputStream fo; //--- Private constructor private BMPFile() { @@ -85,7 +87,7 @@ public class BMPFile extends Component { public static void saveBitmap(Image image, File file) throws IOException { BMPFile b = new BMPFile(); - try (FileOutputStream fos = new FileOutputStream(file)) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { b.fo = fos; b.save(image, image.getWidth(null), image.getHeight(null)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FileTextWriter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FileTextWriter.java index e207d75db..84168cf2f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FileTextWriter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FileTextWriter.java @@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.helpers; import com.jpexs.decompiler.flash.helpers.hilight.HighlightData; import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType; import com.jpexs.helpers.utf8.Utf8OutputStreamWriter; -import java.io.BufferedWriter; +import java.io.BufferedOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.Writer; @@ -43,7 +43,7 @@ public class FileTextWriter extends GraphTextWriter implements AutoCloseable { public FileTextWriter(CodeFormatting formatting, FileOutputStream fos) { super(formatting); - this.writer = new BufferedWriter(new Utf8OutputStreamWriter(fos)); + this.writer = new Utf8OutputStreamWriter(new BufferedOutputStream(fos)); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java index 0544414d5..de0333f4c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java @@ -30,6 +30,7 @@ import java.awt.Shape; import java.awt.geom.Area; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; +import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -843,9 +844,9 @@ public class Helper { } public static void saveStream(InputStream is, File output) throws IOException { - byte[] buf = new byte[1024]; + byte[] buf = new byte[4096]; int cnt; - try (FileOutputStream fos = new FileOutputStream(output)) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(output))) { while ((cnt = is.read(buf)) > 0) { fos.write(buf, 0, cnt); fos.flush(); diff --git a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java index 7aa7e193f..b90f9e974 100644 --- a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java +++ b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java @@ -1210,7 +1210,7 @@ public class CommandLineArgumentParser { String xml = Helper.readTextFile(args.pop()); SWF swf = new SWF(); new SwfXmlImporter().importSwf(swf, xml); - try (FileOutputStream fos = new FileOutputStream(new File(args.pop()))) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(new File(args.pop())))) { swf.saveTo(new BufferedOutputStream(fos)); } } catch (IOException ex) { @@ -1400,7 +1400,7 @@ public class CommandLineArgumentParser { DefineSpriteTag ds = (DefineSpriteTag) t; if ("page1".equals(ds.getExportName())) { page = 1; - job = new PDFJob(new FileOutputStream(outFile)); + job = new PDFJob(new BufferedOutputStream(new FileOutputStream(outFile))); } else { if (page > 0) { page++; @@ -1550,7 +1550,7 @@ public class CommandLineArgumentParser { } try { - try (FileOutputStream fos = new FileOutputStream(outFile)) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(outFile))) { swf.saveTo(fos); } } catch (IOException e) { diff --git a/src/com/jpexs/decompiler/flash/gui/LicenseUpdater.java b/src/com/jpexs/decompiler/flash/gui/LicenseUpdater.java index dab8ea06f..bc482d922 100644 --- a/src/com/jpexs/decompiler/flash/gui/LicenseUpdater.java +++ b/src/com/jpexs/decompiler/flash/gui/LicenseUpdater.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.helpers.utf8.Utf8Helper; import com.jpexs.helpers.utf8.Utf8PrintWriter; +import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.File; @@ -25,6 +26,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.io.OutputStream; import java.io.PrintWriter; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -137,7 +139,7 @@ public class LicenseUpdater { } catch (IOException ex) { } - try (FileOutputStream fos = new FileOutputStream(f)) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(f))) { fos.write(baos.toByteArray()); } catch (IOException ex) { } diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 33a5caaf7..3eeb5b087 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -56,6 +56,7 @@ import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -64,6 +65,7 @@ import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.OutputStream; import java.lang.reflect.Field; import java.net.InetSocketAddress; import java.net.Proxy; @@ -386,7 +388,7 @@ public class Main { } File outfileF = new File(outfile); File tmpFile = new File(outfile + ".tmp"); - try (FileOutputStream fos = new FileOutputStream(tmpFile)) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(tmpFile))) { if (mode == SaveFileMode.EXE) { InputStream exeStream = View.class.getClassLoader().getResourceAsStream("com/jpexs/helpers/resource/Swf2Exe.bin"); byte[] buffer = new byte[4096]; diff --git a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java index 983a56687..193aea2fc 100644 --- a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java @@ -1126,8 +1126,8 @@ public class PreviewPanel extends JSplitPane implements ActionListener { } try { tempFile = File.createTempFile("ffdec_view_", ".swf"); - try (FileOutputStream fos = new FileOutputStream(tempFile)) { - swf.saveTo(new BufferedOutputStream(fos)); + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(tempFile))) { + swf.saveTo(fos); } flashPanel.displaySWF(tempFile.getAbsolutePath(), backgroundColor, swf.frameRate); } catch (IOException iex) { diff --git a/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java b/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java index 91009ac23..f5e70bc6b 100644 --- a/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java +++ b/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java @@ -37,9 +37,11 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -210,7 +212,7 @@ public class DumpTree extends JTree implements ActionListener { View.setWindowIcon(f); if (fc.showSaveDialog(f) == JFileChooser.APPROVE_OPTION) { File sf = Helper.fixDialogFile(fc.getSelectedFile()); - try (FileOutputStream fos = new FileOutputStream(sf)) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(sf))) { byte[] data = DumpInfoSwfNode.getSwfNode(dumpInfo).getSwf().originalUncompressedData; fos.write(data, (int) dumpInfo.startByte, (int) (dumpInfo.getEndByte() - dumpInfo.startByte + 1)); } catch (IOException ex) { diff --git a/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java b/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java index fcd456691..d3323e1c0 100644 --- a/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java +++ b/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java @@ -55,6 +55,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; import java.io.PrintWriter; import java.nio.file.Files; import java.nio.file.StandardCopyOption; @@ -720,7 +721,7 @@ public class ProxyFrame extends AppFrame implements ActionListener, CatchedListe String tempFilePath = Main.tempFile(url); data.reset(); byte[] dataArray = Helper.readStream(data); - try (FileOutputStream fos = new FileOutputStream(new File(tempFilePath))) { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(new File(tempFilePath)))) { fos.write(dataArray); }