diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index 93e6ff114..6244066d3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -115,7 +115,6 @@ import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -476,8 +475,6 @@ public final class SWF { fis.close(); fos.close(); - } catch (FileNotFoundException ex) { - return false; } catch (IOException ex) { return false; } @@ -540,8 +537,6 @@ public final class SWF { default: return false; } - } catch (FileNotFoundException ex) { - return false; } catch (IOException ex) { return false; } @@ -557,8 +552,6 @@ public final class SWF { swf.saveTo(fos); } catch (InterruptedException ex) { return false; - } catch (FileNotFoundException ex) { - return false; } catch (IOException ex) { return false; } diff --git a/trunk/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/trunk/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java index 9d43800bf..f74bb0fe7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java +++ b/trunk/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java @@ -33,6 +33,8 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.util.Arrays; import java.util.LinkedList; import java.util.Queue; @@ -535,33 +537,46 @@ public class CommandLineArgumentParser { } } - private static void parseCompress(Queue args) throws FileNotFoundException { + private static void parseCompress(Queue args) { + if (args.size() < 2) { + badArguments(); + } + try { + InputStream fis = new FileInputStream(args.remove()); + OutputStream fos = new FileOutputStream(args.remove()); + if (SWF.fws2cws(fis, fos)) { + System.out.println("OK"); + } else { + System.err.println("FAIL"); + } + } catch (FileNotFoundException ex) { + System.err.println("File not found."); + } + System.exit(0); + } + + private static void parseDecompress(Queue args) { if (args.size() < 2) { badArguments(); } - if (SWF.fws2cws(new FileInputStream(args.remove()), new FileOutputStream(args.remove()))) { - System.out.println("OK"); - } else { - System.err.println("FAIL"); + try { + InputStream fis = new FileInputStream(args.remove()); + OutputStream fos = new FileOutputStream(args.remove()); + if (SWF.decompress(fis, fos)) { + System.out.println("OK"); + System.exit(0); + } else { + System.err.println("FAIL"); + System.exit(1); + } + } catch (FileNotFoundException ex) { + System.err.println("File not found."); } + System.exit(0); } - private static void parseDecompress(Queue args) throws FileNotFoundException { - if (args.size() < 2) { - badArguments(); - } - - if (SWF.decompress(new FileInputStream(args.remove()), new FileOutputStream(args.remove()))) { - System.out.println("OK"); - System.exit(0); - } else { - System.err.println("FAIL"); - System.exit(1); - } - } - - private static void parseRenameInvalidIdentifiers(Queue args) throws FileNotFoundException { + private static void parseRenameInvalidIdentifiers(Queue args) { if (args.size() < 3) { badArguments(); } @@ -580,13 +595,20 @@ public class CommandLineArgumentParser { badArguments(); return; } - if (SWF.renameInvalidIdentifiers(renameType, new FileInputStream(args.remove()), new FileOutputStream(args.remove()))) { - System.out.println("OK"); - System.exit(0); - } else { - System.err.println("FAIL"); - System.exit(1); + try { + InputStream fis = new FileInputStream(args.remove()); + OutputStream fos = new FileOutputStream(args.remove()); + if (SWF.renameInvalidIdentifiers(renameType, fis, fos)) { + System.out.println("OK"); + System.exit(0); + } else { + System.err.println("FAIL"); + System.exit(1); + } + } catch (FileNotFoundException ex) { + System.err.println("File not found."); } + System.exit(0); } private static void parseDumpSwf(Queue args) {