public abstract class RocketLoader {
protected final WarningSet warnings = new WarningSet();
-
+
/**
* Loads a rocket from the specified File object.
*/
public final OpenRocketDocument load(File source) throws RocketLoadException {
warnings.clear();
+ InputStream stream = null;
try {
- return load(new BufferedInputStream(new FileInputStream(source)));
+
+ stream = new BufferedInputStream(new FileInputStream(source));
+ return load(stream);
+
} catch (FileNotFoundException e) {
throw new RocketLoadException("File not found: " + source);
+ } finally {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}
}
throw e;
} catch (IOException e) {
throw new RocketLoadException("I/O error: " + e.getMessage());
- } catch (Exception e) {
- throw new RocketLoadException("An unknown error occurred. Please report a bug.", e);
- } catch (Throwable e) {
- throw new RocketLoadException("A serious error occurred and the software may be "
- + "unstable. Save your designs and restart OpenRocket.", e);
}
}