1717package org .apache .commons .io ;
1818
1919import java .nio .charset .Charset ;
20+ import java .nio .charset .StandardCharsets ;
2021import java .util .Collections ;
2122import java .util .SortedMap ;
2223import java .util .TreeMap ;
@@ -72,14 +73,13 @@ public class Charsets {
7273 */
7374 public static SortedMap <String , Charset > requiredCharsets () {
7475 // maybe cache?
75- // TODO Re-implement on Java 7 to use java.nio.charset.StandardCharsets
7676 final TreeMap <String , Charset > m = new TreeMap <>(String .CASE_INSENSITIVE_ORDER );
77- m .put (ISO_8859_1 .name (), ISO_8859_1 );
78- m .put (US_ASCII .name (), US_ASCII );
79- m .put (UTF_16 .name (), UTF_16 );
80- m .put (UTF_16BE .name (), UTF_16BE );
81- m .put (UTF_16LE .name (), UTF_16LE );
82- m .put (UTF_8 .name (), UTF_8 );
77+ m .put (StandardCharsets . ISO_8859_1 .name (), StandardCharsets . ISO_8859_1 );
78+ m .put (StandardCharsets . US_ASCII .name (), StandardCharsets . US_ASCII );
79+ m .put (StandardCharsets . UTF_16 .name (), StandardCharsets . UTF_16 );
80+ m .put (StandardCharsets . UTF_16BE .name (), StandardCharsets . UTF_16BE );
81+ m .put (StandardCharsets . UTF_16LE .name (), StandardCharsets . UTF_16LE );
82+ m .put (StandardCharsets . UTF_8 .name (), StandardCharsets . UTF_8 );
8383 return Collections .unmodifiableSortedMap (m );
8484 }
8585
@@ -117,7 +117,7 @@ public static Charset toCharset(final String charset) {
117117 * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
118118 */
119119 @ Deprecated
120- public static final Charset ISO_8859_1 = Charset . forName ( "ISO-8859-1" ) ;
120+ public static final Charset ISO_8859_1 = StandardCharsets . ISO_8859_1 ;
121121
122122 /**
123123 * <p>
@@ -131,7 +131,7 @@ public static Charset toCharset(final String charset) {
131131 * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
132132 */
133133 @ Deprecated
134- public static final Charset US_ASCII = Charset . forName ( "US-ASCII" ) ;
134+ public static final Charset US_ASCII = StandardCharsets . US_ASCII ;
135135
136136 /**
137137 * <p>
@@ -146,7 +146,7 @@ public static Charset toCharset(final String charset) {
146146 * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
147147 */
148148 @ Deprecated
149- public static final Charset UTF_16 = Charset . forName ( "UTF-16" ) ;
149+ public static final Charset UTF_16 = StandardCharsets . UTF_16 ;
150150
151151 /**
152152 * <p>
@@ -160,7 +160,7 @@ public static Charset toCharset(final String charset) {
160160 * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
161161 */
162162 @ Deprecated
163- public static final Charset UTF_16BE = Charset . forName ( "UTF-16BE" ) ;
163+ public static final Charset UTF_16BE = StandardCharsets . UTF_16BE ;
164164
165165 /**
166166 * <p>
@@ -174,7 +174,7 @@ public static Charset toCharset(final String charset) {
174174 * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
175175 */
176176 @ Deprecated
177- public static final Charset UTF_16LE = Charset . forName ( "UTF-16LE" ) ;
177+ public static final Charset UTF_16LE = StandardCharsets . UTF_16LE ;
178178
179179 /**
180180 * <p>
@@ -188,5 +188,5 @@ public static Charset toCharset(final String charset) {
188188 * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
189189 */
190190 @ Deprecated
191- public static final Charset UTF_8 = Charset . forName ( "UTF-8" ) ;
191+ public static final Charset UTF_8 = StandardCharsets . UTF_8 ;
192192}
0 commit comments