< prev index next >

src/java.base/share/classes/java/nio/file/Files.java

Print this page
rev 49550 : 8201179: Regression due loading java.nio.charset.StandardCharsets during bootstrap
Reviewed-by: sherman

@@ -75,10 +75,11 @@
 import java.util.Spliterators;
 import java.util.function.BiPredicate;
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
 
+import sun.nio.cs.UTF_8;
 import sun.nio.fs.AbstractFileSystemProvider;
 
 /**
  * This class consists exclusively of static methods that operate on files,
  * directories, or other types of files.

@@ -2857,11 +2858,11 @@
      *          method is invoked to check read access to the file.
      *
      * @since 1.8
      */
     public static BufferedReader newBufferedReader(Path path) throws IOException {
-        return newBufferedReader(path, StandardCharsets.UTF_8);
+        return newBufferedReader(path, UTF_8.INSTANCE);
     }
 
     /**
      * Opens or creates a file for writing, returning a {@code BufferedWriter}
      * that may be used to write text to the file in an efficient manner.

@@ -2949,11 +2950,11 @@
      * @since 1.8
      */
     public static BufferedWriter newBufferedWriter(Path path, OpenOption... options)
         throws IOException
     {
-        return newBufferedWriter(path, StandardCharsets.UTF_8, options);
+        return newBufferedWriter(path, UTF_8.INSTANCE, options);
     }
 
     /**
      * Copies all bytes from an input stream to a file. On return, the input
      * stream will be at end of stream.

@@ -3279,11 +3280,11 @@
      *          method is invoked to check read access to the file.
      *
      * @since 1.8
      */
     public static List<String> readAllLines(Path path) throws IOException {
-        return readAllLines(path, StandardCharsets.UTF_8);
+        return readAllLines(path, UTF_8.INSTANCE);
     }
 
     /**
      * Writes bytes to a file. The {@code options} parameter specifies how
      * the file is created or opened. If no options are present then this method

@@ -3450,11 +3451,11 @@
     public static Path write(Path path,
                              Iterable<? extends CharSequence> lines,
                              OpenOption... options)
         throws IOException
     {
-        return write(path, lines, StandardCharsets.UTF_8, options);
+        return write(path, lines, UTF_8.INSTANCE, options);
     }
 
     // -- Stream APIs --
 
     /**

@@ -3937,8 +3938,8 @@
      *          method is invoked to check read access to the file.
      *
      * @since 1.8
      */
     public static Stream<String> lines(Path path) throws IOException {
-        return lines(path, StandardCharsets.UTF_8);
+        return lines(path, UTF_8.INSTANCE);
     }
 }
< prev index next >