8302979: (fs) Files usage of SUPPORTED_CHARSETS could be simplified

Reviewed-by: alanb, jwaters
This commit is contained in:
Sergey Tsypanov 2023-02-22 14:08:51 +00:00 committed by Julian Waters
parent 0d5f7439a4
commit 25bfed3b12
2 changed files with 8 additions and 11 deletions

View file

@ -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;