changeset 11230:6249ced5ff69

8067173: remove Utils::fileAsList Reviewed-by: kvn, iignatyev
author tpivovarova
date Wed, 24 Dec 2014 17:54:00 +0300
parents 056d714569dc
children 5aec1b06349c
files test/lib/testlibrary/jdk/testlibrary/Utils.java test/sun/tools/jcmd/TestJcmdDefaults.java test/sun/tools/jcmd/TestJcmdSanity.java test/sun/tools/jps/JpsHelper.java
diffstat 4 files changed, 18 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/test/lib/testlibrary/jdk/testlibrary/Utils.java	Fri Dec 19 17:01:45 2014 -0800
+++ b/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/test/sun/tools/jcmd/TestJcmdDefaults.java	Fri Dec 19 17:01:45 2014 -0800
+++ b/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/test/sun/tools/jcmd/TestJcmdSanity.java	Fri Dec 19 17:01:45 2014 -0800
+++ b/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/test/sun/tools/jps/JpsHelper.java	Fri Dec 19 17:01:45 2014 -0800
+++ b/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 {