--- a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java Fri Dec 19 17:01:45 2014 -0800
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java Wed Dec 24 17:54:00 2014 +0300
@@ -271,25 +271,6 @@
}
/**
- * Returns file content as a list of strings
- *
- * @param file File to operate on
- * @return List of strings
- * @throws IOException
- */
- public static List<String> fileAsList(File file) throws IOException {
- assertTrue(file.exists() && file.isFile(),
- file.getAbsolutePath() + " does not exist or not a file");
- List<String> output = new ArrayList<>();
- try (BufferedReader reader = new BufferedReader(new FileReader(file.getAbsolutePath()))) {
- while (reader.ready()) {
- output.add(reader.readLine().replace(NEW_LINE, ""));
- }
- }
- return output;
- }
-
- /**
* Adjusts the provided timeout value for the TIMEOUT_FACTOR
* @param tOut the timeout value to be adjusted
* @return The timeout value adjusted for the value of "test.timeout.factor"
--- a/jdk/test/sun/tools/jcmd/TestJcmdDefaults.java Fri Dec 19 17:01:45 2014 -0800
+++ b/jdk/test/sun/tools/jcmd/TestJcmdDefaults.java Wed Dec 24 17:54:00 2014 +0300
@@ -25,6 +25,9 @@
import java.io.File;
import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.List;
import jdk.testlibrary.JcmdBase;
@@ -95,11 +98,11 @@
}
private static void verifyOutputAgainstFile(OutputAnalyzer output) throws IOException {
- File file = new File(TEST_SRC, "usage.out");
- List<String> fileOutput = Utils.fileAsList(file);
+ Path path = Paths.get(TEST_SRC, "usage.out");
+ List<String> fileOutput = Files.readAllLines(path);
List<String> outputAsLines = output.asLines();
assertTrue(outputAsLines.containsAll(fileOutput),
- "The ouput should contain all content of " + file.getAbsolutePath());
+ "The ouput should contain all content of " + path.toAbsolutePath());
}
}
--- a/jdk/test/sun/tools/jcmd/TestJcmdSanity.java Fri Dec 19 17:01:45 2014 -0800
+++ b/jdk/test/sun/tools/jcmd/TestJcmdSanity.java Wed Dec 24 17:54:00 2014 +0300
@@ -25,6 +25,9 @@
import java.io.File;
import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.List;
import jdk.testlibrary.JcmdBase;
@@ -160,11 +163,11 @@
}
private static void verifyOutputAgainstFile(OutputAnalyzer output) throws IOException {
- File file = new File(TEST_SRC, "help_help.out");
- List<String> fileOutput = Utils.fileAsList(file);
+ Path path = Paths.get(TEST_SRC, "help_help.out");
+ List<String> fileOutput = Files.readAllLines(path);
List<String> outputAsLines = output.asLines();
assertTrue(outputAsLines.containsAll(fileOutput),
- "The ouput should contain all content of " + file.getAbsolutePath());
+ "The ouput should contain all content of " + path.toAbsolutePath());
}
}
--- a/jdk/test/sun/tools/jps/JpsHelper.java Fri Dec 19 17:01:45 2014 -0800
+++ b/jdk/test/sun/tools/jps/JpsHelper.java Wed Dec 24 17:54:00 2014 +0300
@@ -28,6 +28,9 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -189,11 +192,11 @@
*/
public static void verifyOutputAgainstFile(OutputAnalyzer output) throws IOException {
String testSrc = System.getProperty("test.src", "?");
- File file = new File(testSrc, "usage.out");
- List<String> fileOutput = Utils.fileAsList(file);
+ Path path = Paths.get(testSrc, "usage.out");
+ List<String> fileOutput = Files.readAllLines(path);
List<String> outputAsLines = output.asLines();
assertTrue(outputAsLines.containsAll(fileOutput),
- "The ouput should contain all content of " + file.getAbsolutePath());
+ "The ouput should contain all content of " + path.toAbsolutePath());
}
private static File getManifest(String className) throws IOException {