Utilize StandardCharsets

Closes gh-10972
This commit is contained in:
Johnny Lim
2017-11-10 05:43:06 +09:00
committed by Stephane Nicoll
parent e9c81bf702
commit bd0dcfb172
30 changed files with 77 additions and 85 deletions

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.loader.jar;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
/**
* Simple wrapper around a byte array that represents an ASCII. Used for performance
@@ -27,8 +27,6 @@ import java.nio.charset.Charset;
*/
final class AsciiBytes {
private static final Charset UTF_8 = Charset.forName("UTF-8");
private final byte[] bytes;
private final int offset;
@@ -44,7 +42,7 @@ final class AsciiBytes {
* @param string the source string
*/
AsciiBytes(String string) {
this(string.getBytes(UTF_8));
this(string.getBytes(StandardCharsets.UTF_8));
this.string = string;
}
@@ -124,7 +122,7 @@ final class AsciiBytes {
if (string == null || string.isEmpty()) {
return this;
}
return append(string.getBytes(UTF_8));
return append(string.getBytes(StandardCharsets.UTF_8));
}
public AsciiBytes append(AsciiBytes asciiBytes) {
@@ -147,7 +145,7 @@ final class AsciiBytes {
@Override
public String toString() {
if (this.string == null) {
this.string = new String(this.bytes, this.offset, this.length, UTF_8);
this.string = new String(this.bytes, this.offset, this.length, StandardCharsets.UTF_8);
}
return this.string;
}
@@ -215,7 +213,7 @@ final class AsciiBytes {
}
static String toString(byte[] bytes) {
return new String(bytes, UTF_8);
return new String(bytes, StandardCharsets.UTF_8);
}
public static int hashCode(String string) {