mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8302979: (fs) Files usage of SUPPORTED_CHARSETS could be simplified
Reviewed-by: alanb, jwaters
This commit is contained in:
parent
0d5f7439a4
commit
25bfed3b12
2 changed files with 8 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -36,7 +36,6 @@ import java.nio.channels.Channels;
|
|||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Spliterator;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
@ -70,13 +69,11 @@ import jdk.internal.access.JavaNioAccess;
|
|||
*/
|
||||
final class FileChannelLinesSpliterator implements Spliterator<String> {
|
||||
|
||||
static final Set<String> SUPPORTED_CHARSET_NAMES;
|
||||
static {
|
||||
SUPPORTED_CHARSET_NAMES = new HashSet<>();
|
||||
SUPPORTED_CHARSET_NAMES.add(UTF_8.INSTANCE.name());
|
||||
SUPPORTED_CHARSET_NAMES.add(ISO_8859_1.INSTANCE.name());
|
||||
SUPPORTED_CHARSET_NAMES.add(US_ASCII.INSTANCE.name());
|
||||
}
|
||||
static final Set<Charset> SUPPORTED_CHARSETS = Set.of(
|
||||
UTF_8.INSTANCE,
|
||||
ISO_8859_1.INSTANCE,
|
||||
US_ASCII.INSTANCE
|
||||
);
|
||||
|
||||
private final FileChannel fc;
|
||||
private final Charset cs;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -4103,7 +4103,7 @@ public final class Files {
|
|||
// 3) the file size is such that all bytes can be indexed by int values
|
||||
// (this limitation is imposed by ByteBuffer)
|
||||
if (path.getFileSystem() == FileSystems.getDefault() &&
|
||||
FileChannelLinesSpliterator.SUPPORTED_CHARSET_NAMES.contains(cs.name())) {
|
||||
FileChannelLinesSpliterator.SUPPORTED_CHARSETS.contains(cs)) {
|
||||
FileChannel fc = FileChannel.open(path, StandardOpenOption.READ);
|
||||
|
||||
Stream<String> fcls = createFileChannelLinesStream(fc, cs);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue