Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Kleese2017-07-17 14:40:47 -0400
committerAlexander Kurtakov2017-07-18 03:24:35 -0400
commit0e3e18a515a1b920b47e17e6b20aa25bbf1db363 (patch)
treef164ad7d13f22f4dd5933d0ba3c62241106509e9 /org.eclipse.ui.workbench.texteditor
parent51c20319307866951c92a5d620fd8f97c2f2da52 (diff)
downloadeclipse.platform.text-0e3e18a515a1b920b47e17e6b20aa25bbf1db363.tar.gz
eclipse.platform.text-0e3e18a515a1b920b47e17e6b20aa25bbf1db363.tar.xz
eclipse.platform.text-0e3e18a515a1b920b47e17e6b20aa25bbf1db363.zip
Bug 519779 - [refactoring] Manage resources with try-with-resources
Change-Id: I17f20b317c8e4f854fec5b810a9023357d597c20 Signed-off-by: Shawn Kleese <shawn.kleese@wtnet.de>
Diffstat (limited to 'org.eclipse.ui.workbench.texteditor')
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java21
1 files changed, 2 insertions, 19 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java
index c232995ef..9f6e469ba 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java
@@ -1315,8 +1315,7 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
TemplateReaderWriter reader= new TemplateReaderWriter();
File file= new File(path);
if (file.exists()) {
- InputStream input= new BufferedInputStream(new FileInputStream(file));
- try {
+ try (InputStream input = new BufferedInputStream(new FileInputStream(file))) {
TemplatePersistenceData[] datas= reader.read(input, null);
for (int i= 0; i < datas.length; i++) {
TemplatePersistenceData data= datas[i];
@@ -1331,12 +1330,6 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
}
}
}
- } finally {
- try {
- input.close();
- } catch (IOException x) {
- // ignore
- }
}
}
@@ -1391,21 +1384,11 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
}
if (!file.exists() || confirmOverwrite(file)) {
- OutputStream output= null;
- try {
- output= new BufferedOutputStream(new FileOutputStream(file));
+ try (OutputStream output = new BufferedOutputStream(new FileOutputStream(file))) {
TemplateReaderWriter writer= new TemplateReaderWriter();
writer.save(templates, output);
} catch (IOException e) {
openWriteErrorDialog(e);
- } finally {
- if (output != null) {
- try {
- output.close();
- } catch (IOException e) {
- // ignore
- }
- }
}
}
}

Back to the top