package net.sf.openrocket.file;
-import java.awt.Component;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import javax.swing.ProgressMonitorInputStream;
-
import net.sf.openrocket.aerodynamics.WarningSet;
import net.sf.openrocket.document.OpenRocketDocument;
protected final WarningSet warnings = new WarningSet();
- public final OpenRocketDocument load(File source, Component parent)
- throws RocketLoadException {
- warnings.clear();
-
- try {
- return load(new BufferedInputStream(new ProgressMonitorInputStream(
- parent, "Loading " + source.getName(),
- new FileInputStream(source))));
- } catch (FileNotFoundException e) {
- throw new RocketLoadException("File not found: " + source);
- }
- }
-
/**
* 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();
+ }
+ }
}
}