Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2016-02-19 06:42:34 +0000
committerAlexander Kurtakov2016-02-19 06:42:34 +0000
commit7bb252ce081ff886475ba1eb8acc4eeda99f6267 (patch)
treeb97bdad0eb5c1518e57c737b8cf96922635f67c1 /org.eclipse.ua.tests/base/org/eclipse/ua/tests/util
parent406539b07bfefe96f008098522f257fc91183415 (diff)
downloadeclipse.platform.ua-7bb252ce081ff886475ba1eb8acc4eeda99f6267.tar.gz
eclipse.platform.ua-7bb252ce081ff886475ba1eb8acc4eeda99f6267.tar.xz
eclipse.platform.ua-7bb252ce081ff886475ba1eb8acc4eeda99f6267.zip
Bug 488072 - Move o.e.ua.tests to Java 8
Fix all the new warnings: * try-with-resources * useless type definitions Change-Id: Ib03065e19467d1ce094fe2345ee391f2a987b781 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'org.eclipse.ua.tests/base/org/eclipse/ua/tests/util')
-rw-r--r--org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java28
-rw-r--r--org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/ResourceFinder.java4
-rw-r--r--org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XMLUtil.java7
3 files changed, 19 insertions, 20 deletions
diff --git a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java
index 6fe185300..e0eb15af3 100644
--- a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java
+++ b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2015 IBM Corporation and others.
+ * Copyright (c) 2005, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -56,19 +56,19 @@ public class FileUtil {
* as a String.
*/
public static String readString(InputStream in) throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- byte[] buffer = new byte[4096];
- int num;
- while ((num = in.read(buffer)) > 0) {
- out.write(buffer, 0, num);
+ try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
+ byte[] buffer = new byte[4096];
+ int num;
+ while ((num = in.read(buffer)) > 0) {
+ out.write(buffer, 0, num);
+ }
+ String result = new String(out.toByteArray(), "UTF-8");
+ if (result.length() > 0) {
+ // filter windows-specific newline
+ result = result.replaceAll("\r", "");
+ }
+ // ignore whitespace at start or end
+ return result.trim();
}
- String result = new String(out.toByteArray(), "UTF-8");
- if (result.length() > 0) {
- // filter windows-specific newline
- result = result.replaceAll("\r", "");
- }
- out.close();
- // ignore whitespace at start or end
- return result.trim();
}
}
diff --git a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/ResourceFinder.java b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/ResourceFinder.java
index 2162a828d..3500f7828 100644
--- a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/ResourceFinder.java
+++ b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/ResourceFinder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2015 IBM Corporation and others.
+ * Copyright (c) 2002, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -62,7 +62,7 @@ public class ResourceFinder {
* recursively traverses subdirectories if requested.
*/
private static URL[] findFiles(File[] files, String suffix, boolean recursive) {
- List<URL> list = new ArrayList<URL>();
+ List<URL> list = new ArrayList<>();
if (files != null) {
for (File file : files) {
if (file.isDirectory()) {
diff --git a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XMLUtil.java b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XMLUtil.java
index f6540bc69..6833e4a83 100644
--- a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XMLUtil.java
+++ b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/XMLUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2015 IBM Corporation and others.
+ * Copyright (c) 2006, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,6 +22,7 @@ import java.util.List;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
+import org.eclipse.help.internal.entityresolver.LocalEntityResolver;
import org.junit.Assert;
import org.xml.sax.Attributes;
import org.xml.sax.EntityResolver;
@@ -29,8 +30,6 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
-import org.eclipse.help.internal.entityresolver.LocalEntityResolver;
-
/**
* A utility class for working with XML.
*/
@@ -78,7 +77,7 @@ public class XMLUtil extends Assert {
buf.append('<');
buf.append(qName);
- List<String> list = new ArrayList<String>();
+ List<String> list = new ArrayList<>();
for (int i=0;i<attributes.getLength();++i) {
list.add(attributes.getQName(i));
}

Back to the top