diff options
author | Jeremias Maerki <jeremias@apache.org> | 2003-01-27 09:25:19 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2003-01-27 09:25:19 +0000 |
commit | d8083ea2caf157b15b963c2534aad13d055e5715 (patch) | |
tree | 3fc8fadc53444b77c1e8eb330d206fd1039e23e2 /src/org | |
parent | 771585692a28aaa50326e5c31967539a1dfc8844 (diff) | |
download | xmlgraphics-fop-d8083ea2caf157b15b963c2534aad13d055e5715.tar.gz xmlgraphics-fop-d8083ea2caf157b15b963c2534aad13d055e5715.zip |
Make sure OutputStream gets closed in case of an Exception
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195901 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/apache/fop/apps/CommandLineStarter.java | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/org/apache/fop/apps/CommandLineStarter.java b/src/org/apache/fop/apps/CommandLineStarter.java index 744d54005..befa7010a 100644 --- a/src/org/apache/fop/apps/CommandLineStarter.java +++ b/src/org/apache/fop/apps/CommandLineStarter.java @@ -50,13 +50,16 @@ public class CommandLineStarter extends Starter { driver.setRenderer(commandLineOptions.getRenderer()); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream( commandLineOptions.getOutputFile())); - driver.setOutputStream(bos); - if (driver.getRenderer() != null) { - driver.getRenderer().setOptions( - commandLineOptions.getRendererOptions()); + try { + driver.setOutputStream(bos); + if (driver.getRenderer() != null) { + driver.getRenderer().setOptions( + commandLineOptions.getRendererOptions()); + } + driver.render(parser, inputHandler.getInputSource()); + } finally { + bos.close(); } - driver.render(parser, inputHandler.getInputSource()); - bos.close(); System.exit(0); } catch (Exception e) { if (e instanceof FOPException) { |