Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2015-09-03 10:09:18 +0000
committerAlexander Kurtakov2015-09-03 10:09:18 +0000
commitf3301548d851656ab0edea491c3107b50bc63d93 (patch)
tree807b63acbd395fb884530c4d4e32025b915b00e9 /examples
parentbcf17a5b40f08be13e354f23b9b5268478a155f7 (diff)
downloadeclipse.platform.swt-f3301548d851656ab0edea491c3107b50bc63d93.tar.gz
eclipse.platform.swt-f3301548d851656ab0edea491c3107b50bc63d93.tar.xz
eclipse.platform.swt-f3301548d851656ab0edea491c3107b50bc63d93.zip
Bug 476529 - Move swt.snippets to Java 1.7
* Bump BREE * Remove redundant type arguments * Use try-with-resources. Change-Id: I4bc951d00fac08f35a0bd0f967505b4bb8c0d377 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.swt.snippets/.classpath2
-rw-r--r--examples/org.eclipse.swt.snippets/.settings/org.eclipse.jdt.core.prefs95
-rw-r--r--examples/org.eclipse.swt.snippets/META-INF/MANIFEST.MF2
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet133.java48
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet154.java18
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet171.java20
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet352.java2
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet79.java13
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/SnippetLauncher.java16
9 files changed, 144 insertions, 72 deletions
diff --git a/examples/org.eclipse.swt.snippets/.classpath b/examples/org.eclipse.swt.snippets/.classpath
index ad32c83a78..098194ca4b 100644
--- a/examples/org.eclipse.swt.snippets/.classpath
+++ b/examples/org.eclipse.swt.snippets/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/examples/org.eclipse.swt.snippets/.settings/org.eclipse.jdt.core.prefs b/examples/org.eclipse.swt.snippets/.settings/org.eclipse.jdt.core.prefs
index 8505da607c..089f69d5c0 100644
--- a/examples/org.eclipse.swt.snippets/.settings/org.eclipse.jdt.core.prefs
+++ b/examples/org.eclipse.swt.snippets/.settings/org.eclipse.jdt.core.prefs
@@ -1,12 +1,101 @@
eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/examples/org.eclipse.swt.snippets/META-INF/MANIFEST.MF b/examples/org.eclipse.swt.snippets/META-INF/MANIFEST.MF
index f1d14cd150..132529291e 100644
--- a/examples/org.eclipse.swt.snippets/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.swt.snippets/META-INF/MANIFEST.MF
@@ -6,4 +6,4 @@ Bundle-Version: 3.2.0
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Require-Bundle: org.eclipse.swt
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet133.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet133.java
index 6a1ab6117f..10a35d4ac4 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet133.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet133.java
@@ -17,12 +17,13 @@ package org.eclipse.swt.snippets;
* http://www.eclipse.org/swt/snippets/
*/
import java.io.*;
+
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.printing.*;
+import org.eclipse.swt.widgets.*;
public class Snippet133 {
Display display;
@@ -127,35 +128,34 @@ public class Snippet133 {
void menuOpen() {
final String textString;
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
- dialog.setFilterExtensions(new String[] {"*.java", "*.*"});
+ dialog.setFilterExtensions(new String[] { "*.java", "*.*" });
String name = dialog.open();
- if ((name == null) || (name.length() == 0)) return;
-
- try {
- File file = new File(name);
- FileInputStream stream= new FileInputStream(file.getPath());
- try {
- Reader in = new BufferedReader(new InputStreamReader(stream));
- char[] readBuffer= new char[2048];
- StringBuffer buffer= new StringBuffer((int) file.length());
- int n;
- while ((n = in.read(readBuffer)) > 0) {
- buffer.append(readBuffer, 0, n);
- }
- textString = buffer.toString();
- stream.close();
- } catch (IOException e) {
- MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
- box.setMessage("Error reading file:\n" + name);
- box.open();
- return;
+ if ((name == null) || (name.length() == 0))
+ return;
+
+ File file = new File(name);
+ try (FileInputStream stream = new FileInputStream(file.getPath())) {
+ Reader in = new BufferedReader(new InputStreamReader(stream));
+ char[] readBuffer = new char[2048];
+ StringBuffer buffer = new StringBuffer((int) file.length());
+ int n;
+ while ((n = in.read(readBuffer)) > 0) {
+ buffer.append(readBuffer, 0, n);
}
+ textString = buffer.toString();
+ stream.close();
} catch (FileNotFoundException e) {
MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
box.setMessage("File not found:\n" + name);
box.open();
return;
- }
+ } catch (IOException e) {
+ MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
+ box.setMessage("Error reading file:\n" + name);
+ box.open();
+ return;
+ }
+
text.setText(textString);
}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet154.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet154.java
index 4d7ab7d1c0..7829d5c731 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet154.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet154.java
@@ -18,16 +18,16 @@ package org.eclipse.swt.snippets;
*
* @since 3.0
*/
-import java.awt.BorderLayout;
-import java.awt.Frame;
-import java.awt.Panel;
+import java.awt.*;
+import java.util.*;
+
import javax.swing.*;
-import java.util.Vector;
import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.awt.*;
import org.eclipse.swt.layout.*;
-import org.eclipse.swt.awt.SWT_AWT;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.widgets.Composite;
public class Snippet154 {
@@ -64,15 +64,15 @@ public class Snippet154 {
/* Creating components */
int nrows = 1000, ncolumns = 10;
- Vector<Vector<String>> rows = new Vector<Vector<String>>();
+ Vector<Vector<String>> rows = new Vector<>();
for (int i = 0; i < nrows; i++) {
- Vector<String> row = new Vector<String>();
+ Vector<String> row = new Vector<>();
for (int j = 0; j < ncolumns; j++) {
row.addElement("Item " + i + "-" + j);
}
rows.addElement(row);
}
- Vector<String> columns = new Vector<String>();
+ Vector<String> columns = new Vector<>();
for (int i = 0; i < ncolumns; i++) {
columns.addElement("Column " + i);
}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet171.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet171.java
index 8a9606ab95..277875521e 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet171.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet171.java
@@ -50,9 +50,8 @@ static class MyTransfer extends ByteArrayTransfer {
byte[] javaToByteArray(Object object) {
MyType data = (MyType) object;
- try {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- DataOutputStream writeOut = new DataOutputStream(out);
+ try (ByteArrayOutputStream out = new ByteArrayOutputStream();
+ DataOutputStream writeOut = new DataOutputStream(out)){
byte[] buffer = data.fileName.getBytes();
writeOut.writeInt(buffer.length);
writeOut.write(buffer);
@@ -68,9 +67,8 @@ static class MyTransfer extends ByteArrayTransfer {
Object byteArrayToJava(byte[] bytes) {
MyType data = new MyType();
- try {
- ByteArrayInputStream in = new ByteArrayInputStream(bytes);
- DataInputStream readIn = new DataInputStream(in);
+ try (ByteArrayInputStream in = new ByteArrayInputStream(bytes);
+ DataInputStream readIn = new DataInputStream(in)){
int size = readIn.readInt();
byte[] buffer = new byte[size];
readIn.read(buffer);
@@ -155,9 +153,8 @@ static class MyTransfer2 extends MyTransfer {
@Override
byte[] javaToByteArray(Object object) {
MyType2 data = (MyType2) object;
- try {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- DataOutputStream writeOut = new DataOutputStream(out);
+ try (ByteArrayOutputStream out = new ByteArrayOutputStream();
+ DataOutputStream writeOut = new DataOutputStream(out)) {
byte[] buffer = data.fileName.getBytes();
writeOut.writeInt(buffer.length);
writeOut.write(buffer);
@@ -177,9 +174,8 @@ static class MyTransfer2 extends MyTransfer {
@Override
Object byteArrayToJava(byte[] bytes) {
MyType2 data = new MyType2();
- try {
- ByteArrayInputStream in = new ByteArrayInputStream(bytes);
- DataInputStream readIn = new DataInputStream(in);
+ try (ByteArrayInputStream in = new ByteArrayInputStream(bytes);
+ DataInputStream readIn = new DataInputStream(in)) {
int size = readIn.readInt();
byte[] buffer = new byte[size];
readIn.read(buffer);
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet352.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet352.java
index cc6de82ebc..6f3efdf162 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet352.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet352.java
@@ -40,7 +40,7 @@ public class Snippet352 {
Color color;
}
- static Map<Long, CircleInfo> touchLocations = new HashMap<Long, CircleInfo>();
+ static Map<Long, CircleInfo> touchLocations = new HashMap<>();
static int colorIndex = 0;
static final int PAINTABLE_COLORS = 15;
static final int CIRCLE_RADIUS = 40;
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet79.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet79.java
index 1f76600c14..52c1f3faa5 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet79.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet79.java
@@ -50,10 +50,9 @@ public void javaToNative (Object object, TransferData transferData) {
DND.error(DND.ERROR_INVALID_DATA);
}
MyType [] myTypes = (MyType []) object;
- try {
+ try (ByteArrayOutputStream out = new ByteArrayOutputStream ();
+ DataOutputStream writeOut = new DataOutputStream (out)) {
// write data to a byte array and then ask super to convert to pMedium
- ByteArrayOutputStream out = new ByteArrayOutputStream ();
- DataOutputStream writeOut = new DataOutputStream (out);
for (int i = 0, length = myTypes.length; i < length; i++) {
byte [] buffer = myTypes [i].fileName.getBytes ();
writeOut.writeInt (buffer.length);
@@ -64,8 +63,7 @@ public void javaToNative (Object object, TransferData transferData) {
byte [] buffer = out.toByteArray ();
writeOut.close ();
super.javaToNative (buffer, transferData);
- }
- catch (IOException e) {}
+ } catch (IOException e) {}
}
@Override
@@ -75,9 +73,8 @@ public Object nativeToJava (TransferData transferData) {
if (buffer == null) return null;
MyType [] myData = new MyType [0];
- try {
- ByteArrayInputStream in = new ByteArrayInputStream (buffer);
- DataInputStream readIn = new DataInputStream (in);
+ try (ByteArrayInputStream in = new ByteArrayInputStream (buffer);
+ DataInputStream readIn = new DataInputStream (in)) {
while (readIn.available () > 20) {
MyType datum = new MyType ();
int size = readIn.readInt ();
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/SnippetLauncher.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/SnippetLauncher.java
index 63276c7f0e..15dd97c5e2 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/SnippetLauncher.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/SnippetLauncher.java
@@ -1,5 +1,6 @@
package org.eclipse.swt.snippets;
+import java.io.*;
/*
* Simple "hackable" code that runs all of the SWT Snippets,
* typically for testing. One example of a useful "hack" is
@@ -10,9 +11,8 @@ package org.eclipse.swt.snippets;
* in order to run all of the Table and Tree Snippets.
*/
import java.lang.reflect.*;
-import java.io.*;
-import org.eclipse.swt.SWT;
+import org.eclipse.swt.*;
public class SnippetLauncher {
@@ -35,9 +35,7 @@ public class SnippetLauncher {
System.out.println("\n" + clazz.getName());
if (hasSource) {
File sourceFile = new File(sourceDir, className + ".java");
- FileReader reader = null;
- try {
- reader = new FileReader(sourceFile);
+ try (FileReader reader = new FileReader(sourceFile);){
char [] buffer = new char [(int)sourceFile.length()];
reader.read(buffer);
String source = String.valueOf(buffer);
@@ -71,14 +69,6 @@ public class SnippetLauncher {
continue;
}
} catch (Exception e) {
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException e) {
- // Ignore
- }
- }
}
}
Method method = null;

Back to the top