Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java')
-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 c232995ef26..9f6e469babb 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