8234147: Avoid looking up standard charsets in core libraries

Reviewed-by: alanb
This commit is contained in:
Ivan Gerasimov 2019-12-01 15:29:37 -08:00
parent 4e64af81a2
commit cd589d8469
36 changed files with 200 additions and 237 deletions

View file

@ -79,6 +79,7 @@ import java.util.stream.StreamSupport;
import jdk.internal.util.ArraysSupport;
import sun.nio.ch.FileChannelImpl;
import sun.nio.cs.UTF_8;
import sun.nio.fs.AbstractFileSystemProvider;
/**
@ -2944,7 +2945,7 @@ public final class Files {
* @since 1.8
*/
public static BufferedReader newBufferedReader(Path path) throws IOException {
return newBufferedReader(path, StandardCharsets.UTF_8);
return newBufferedReader(path, UTF_8.INSTANCE);
}
/**
@ -3036,7 +3037,7 @@ public final class Files {
public static BufferedWriter newBufferedWriter(Path path, OpenOption... options)
throws IOException
{
return newBufferedWriter(path, StandardCharsets.UTF_8, options);
return newBufferedWriter(path, UTF_8.INSTANCE, options);
}
/**
@ -3305,7 +3306,7 @@ public final class Files {
* @since 11
*/
public static String readString(Path path) throws IOException {
return readString(path, StandardCharsets.UTF_8);
return readString(path, UTF_8.INSTANCE);
}
/**
@ -3430,7 +3431,7 @@ public final class Files {
* @since 1.8
*/
public static List<String> readAllLines(Path path) throws IOException {
return readAllLines(path, StandardCharsets.UTF_8);
return readAllLines(path, UTF_8.INSTANCE);
}
/**
@ -3601,7 +3602,7 @@ public final class Files {
OpenOption... options)
throws IOException
{
return write(path, lines, StandardCharsets.UTF_8, options);
return write(path, lines, UTF_8.INSTANCE, options);
}
/**
@ -3641,7 +3642,7 @@ public final class Files {
public static Path writeString(Path path, CharSequence csq, OpenOption... options)
throws IOException
{
return writeString(path, csq, StandardCharsets.UTF_8, options);
return writeString(path, csq, UTF_8.INSTANCE, options);
}
/**
@ -4188,6 +4189,6 @@ public final class Files {
* @since 1.8
*/
public static Stream<String> lines(Path path) throws IOException {
return lines(path, StandardCharsets.UTF_8);
return lines(path, UTF_8.INSTANCE);
}
}