Static Public Member Functions | |
static byte[] | getBytesIso8859_1 (final String string) |
static byte[] | getBytesUnchecked (final String string, final String charsetName) |
static byte[] | getBytesUsAscii (final String string) |
static byte[] | getBytesUtf16 (final String string) |
static byte[] | getBytesUtf16Be (final String string) |
static byte[] | getBytesUtf16Le (final String string) |
static byte[] | getBytesUtf8 (final String string) |
static String | newString (final byte[] bytes, final String charsetName) |
static String | newStringIso8859_1 (final byte[] bytes) |
static String | newStringUsAscii (final byte[] bytes) |
static String | newStringUtf16 (final byte[] bytes) |
static String | newStringUtf16Be (final byte[] bytes) |
static String | newStringUtf16Le (final byte[] bytes) |
static String | newStringUtf8 (final byte[] bytes) |
Static Private Member Functions | |
static byte[] | getBytes (final String string, final Charset charset) |
static IllegalStateException | newIllegalStateException (final String charsetName, final UnsupportedEncodingException e) |
static String | newString (final byte[] bytes, final Charset charset) |
Converts String to and from bytes using the encodings required by the Java specification. These encodings are specified in Standard charsets.
This class is immutable and thread-safe.
Definition at line 38 of file StringUtils.java.
|
staticprivate |
Calls String#getBytes(Charset)
string | The string to encode (if null, return null). |
charset | The Charset to encode the String
|
Definition at line 49 of file StringUtils.java.
Referenced by org.apache.commons.codec.binary.StringUtils.getBytesIso8859_1(), org.apache.commons.codec.binary.StringUtils.getBytesUsAscii(), org.apache.commons.codec.binary.StringUtils.getBytesUtf16(), org.apache.commons.codec.binary.StringUtils.getBytesUtf16Be(), org.apache.commons.codec.binary.StringUtils.getBytesUtf16Le(), and org.apache.commons.codec.binary.StringUtils.getBytesUtf8().
|
static |
Encodes the given string into a sequence of bytes using the ISO-8859-1 charset, storing the result into a new byte array.
string | the String to encode, may be null
|
NullPointerException | Thrown if Charsets#ISO_8859_1 is not initialized, which should never happen since it is required by the Java platform specification. |
Definition at line 70 of file StringUtils.java.
References org.apache.commons.codec.binary.StringUtils.getBytes(), and org.apache.commons.codec.Charsets.ISO_8859_1.
|
static |
Encodes the given string into a sequence of bytes using the named charset, storing the result into a new byte array.
This method catches UnsupportedEncodingException and rethrows it as IllegalStateException, which should never happen for a required charset name. Use this method when the encoding is required to be in the JRE.
string | the String to encode, may be null
|
charsetName | The name of a required java.nio.charset.Charset |
IllegalStateException | Thrown when a UnsupportedEncodingException is caught, which should never happen for a required charset name. |
Definition at line 94 of file StringUtils.java.
References org.apache.commons.codec.binary.StringUtils.newIllegalStateException().
|
static |
Encodes the given string into a sequence of bytes using the US-ASCII charset, storing the result into a new byte array.
string | the String to encode, may be null
|
NullPointerException | Thrown if Charsets#US_ASCII is not initialized, which should never happen since it is required by the Java platform specification. |
Definition at line 119 of file StringUtils.java.
References org.apache.commons.codec.binary.StringUtils.getBytes(), and org.apache.commons.codec.Charsets.US_ASCII.
|
static |
Encodes the given string into a sequence of bytes using the UTF-16 charset, storing the result into a new byte array.
string | the String to encode, may be null
|
NullPointerException | Thrown if Charsets#UTF_16 is not initialized, which should never happen since it is required by the Java platform specification. |
Definition at line 137 of file StringUtils.java.
References org.apache.commons.codec.binary.StringUtils.getBytes(), and org.apache.commons.codec.Charsets.UTF_16.
|
static |
Encodes the given string into a sequence of bytes using the UTF-16BE charset, storing the result into a new byte array.
string | the String to encode, may be null
|
NullPointerException | Thrown if Charsets#UTF_16BE is not initialized, which should never happen since it is required by the Java platform specification. |
Definition at line 155 of file StringUtils.java.
References org.apache.commons.codec.binary.StringUtils.getBytes(), and org.apache.commons.codec.Charsets.UTF_16BE.
|
static |
Encodes the given string into a sequence of bytes using the UTF-16LE charset, storing the result into a new byte array.
string | the String to encode, may be null
|
NullPointerException | Thrown if Charsets#UTF_16LE is not initialized, which should never happen since it is required by the Java platform specification. |
Definition at line 173 of file StringUtils.java.
References org.apache.commons.codec.binary.StringUtils.getBytes(), and org.apache.commons.codec.Charsets.UTF_16LE.
|
static |
Encodes the given string into a sequence of bytes using the UTF-8 charset, storing the result into a new byte array.
string | the String to encode, may be null
|
NullPointerException | Thrown if Charsets#UTF_8 is not initialized, which should never happen since it is required by the Java platform specification. |
Definition at line 191 of file StringUtils.java.
References org.apache.commons.codec.binary.StringUtils.getBytes(), and org.apache.commons.codec.Charsets.UTF_8.
Referenced by org.apache.commons.codec.binary.BaseNCodec.decode(), org.apache.commons.codec.binary.Base64.isBase64(), and org.apache.commons.codec.binary.BaseNCodec.isInAlphabet().
|
staticprivate |
Definition at line 195 of file StringUtils.java.
Referenced by org.apache.commons.codec.binary.StringUtils.getBytesUnchecked(), and org.apache.commons.codec.binary.StringUtils.newString().
|
staticprivate |
Constructs a new String
by decoding the specified array of bytes using the given charset.
bytes | The bytes to be decoded into characters |
charset | The Charset to encode the String
|
String
decoded from the specified array of bytes using the given charset, orNullPointerException | Thrown if Charsets#UTF_8 is not initialized, which should never happen since it is required by the Java platform specification. |
Definition at line 213 of file StringUtils.java.
Referenced by org.apache.commons.codec.binary.StringUtils.newStringUtf8().
|
static |
Constructs a new String
by decoding the specified array of bytes using the given charset.
This method catches UnsupportedEncodingException and re-throws it as IllegalStateException, which should never happen for a required charset name. Use this method when the encoding is required to be in the JRE.
bytes | The bytes to be decoded into characters, may be null
|
charsetName | The name of a required java.nio.charset.Charset |
String
decoded from the specified array of bytes using the given charset, orIllegalStateException | Thrown when a UnsupportedEncodingException is caught, which should never happen for a required charset name. |
Definition at line 236 of file StringUtils.java.
References org.apache.commons.codec.binary.StringUtils.newIllegalStateException().
|
static |
Constructs a new String
by decoding the specified array of bytes using the ISO-8859-1 charset.
bytes | The bytes to be decoded into characters, may be null
|
String
decoded from the specified array of bytes using the ISO-8859-1 charset, or NullPointerException | Thrown if Charsets#ISO_8859_1 is not initialized, which should never happen since it is required by the Java platform specification. |
Definition at line 259 of file StringUtils.java.
References org.apache.commons.codec.Charsets.ISO_8859_1.
|
static |
Constructs a new String
by decoding the specified array of bytes using the US-ASCII charset.
bytes | The bytes to be decoded into characters |
String
decoded from the specified array of bytes using the US-ASCII charset, orNullPointerException | Thrown if Charsets#US_ASCII is not initialized, which should never happen since it is required by the Java platform specification. |
Definition at line 275 of file StringUtils.java.
References org.apache.commons.codec.Charsets.US_ASCII.
|
static |
Constructs a new String
by decoding the specified array of bytes using the UTF-16 charset.
bytes | The bytes to be decoded into characters |
String
decoded from the specified array of bytes using the UTF-16 charset orNullPointerException | Thrown if Charsets#UTF_16 is not initialized, which should never happen since it is required by the Java platform specification. |
Definition at line 291 of file StringUtils.java.
References org.apache.commons.codec.Charsets.UTF_16.
|
static |
Constructs a new String
by decoding the specified array of bytes using the UTF-16BE charset.
bytes | The bytes to be decoded into characters |
String
decoded from the specified array of bytes using the UTF-16BE charset, orNullPointerException | Thrown if Charsets#UTF_16BE is not initialized, which should never happen since it is required by the Java platform specification. |
Definition at line 307 of file StringUtils.java.
References org.apache.commons.codec.Charsets.UTF_16BE.
|
static |
Constructs a new String
by decoding the specified array of bytes using the UTF-16LE charset.
bytes | The bytes to be decoded into characters |
String
decoded from the specified array of bytes using the UTF-16LE charset, orNullPointerException | Thrown if Charsets#UTF_16LE is not initialized, which should never happen since it is required by the Java platform specification. |
Definition at line 323 of file StringUtils.java.
References org.apache.commons.codec.Charsets.UTF_16LE.
|
static |
Constructs a new String
by decoding the specified array of bytes using the UTF-8 charset.
bytes | The bytes to be decoded into characters |
String
decoded from the specified array of bytes using the UTF-8 charset, orNullPointerException | Thrown if Charsets#UTF_8 is not initialized, which should never happen since it is required by the Java platform specification. |
Definition at line 339 of file StringUtils.java.
References org.apache.commons.codec.binary.StringUtils.newString(), and org.apache.commons.codec.Charsets.UTF_8.
Referenced by org.apache.commons.codec.binary.Base64.Base64(), org.apache.commons.codec.binary.BaseNCodec.encodeAsString(), org.apache.commons.codec.binary.Base64.encodeBase64String(), org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString(), and org.apache.commons.codec.binary.BaseNCodec.encodeToString().