mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
filestreams closed on save too
This commit is contained in:
@@ -70,12 +70,10 @@ public final class SLayoutIO {
|
||||
throw new IllegalThreadStateException("This operation should be independent of the EDT.");
|
||||
}
|
||||
|
||||
try { save(f0); }
|
||||
catch (final Exception e) { e.printStackTrace(); }
|
||||
|
||||
save(f0);
|
||||
}
|
||||
|
||||
private synchronized static void save(final File f0) throws Exception {
|
||||
private synchronized static void save(final File f0) {
|
||||
final String fWriteTo;
|
||||
FileLocation file = SLayoutIO.getFileForState(Singletons.getControl().getState());
|
||||
|
||||
@@ -90,7 +88,11 @@ public final class SLayoutIO {
|
||||
}
|
||||
|
||||
final XMLOutputFactory out = XMLOutputFactory.newInstance();
|
||||
final XMLEventWriter writer = out.createXMLEventWriter(new FileOutputStream(fWriteTo));
|
||||
FileOutputStream fos = null;
|
||||
XMLEventWriter writer = null;
|
||||
try {
|
||||
fos = new FileOutputStream(fWriteTo);
|
||||
writer = out.createXMLEventWriter(fos);
|
||||
final List<DragCell> cells = FView.SINGLETON_INSTANCE.getDragCells();
|
||||
|
||||
writer.add(EF.createStartDocument());
|
||||
@@ -118,10 +120,21 @@ public final class SLayoutIO {
|
||||
writer.add(EF.createEndElement("", "", "cell"));
|
||||
writer.add(NEWLINE);
|
||||
}
|
||||
|
||||
writer.add(EF.createEndDocument());
|
||||
writer.flush();
|
||||
writer.close();
|
||||
writer.add(EF.createEndDocument());
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log.
|
||||
e.printStackTrace();
|
||||
} catch (XMLStreamException e) {
|
||||
// TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log.
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if ( writer != null )
|
||||
try { writer.close(); } catch (XMLStreamException e) {}
|
||||
|
||||
if ( fos != null )
|
||||
try { fos.close(); } catch (IOException e) {}
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadLayout(final File f) {
|
||||
|
||||
Reference in New Issue
Block a user