ensure resource closing in deckimport from clipboard

This commit is contained in:
Marc Zwart 2018-03-20 15:00:08 +01:00
parent 338e9833cc
commit 1ec5a3fb4d

View file

@ -1,5 +1,7 @@
package mage.client.deckeditor;
import mage.util.StreamUtils;
import java.awt.*;
import java.awt.event.*;
import java.io.BufferedWriter;
@ -39,15 +41,16 @@ public class DeckImportFromClipboardDialog extends JDialog {
}
private void onOK() {
BufferedWriter bw = null;
try {
File temp = File.createTempFile("cbimportdeck", ".txt");
BufferedWriter bw = new BufferedWriter(new FileWriter(temp));
bw = new BufferedWriter(new FileWriter(temp));
bw.write(txtDeckList.getText());
bw.close();
tmpPath = temp.getPath();
} catch (IOException e) {
e.printStackTrace();
} finally {
StreamUtils.closeQuietly(bw);
}
dispose();