public interface ICheckedCharset
It helps to avoid the annoying try-catch code-pollution every time you use a valid encoding, but the API requires the handling of UnsupportedEncodingException even if it cannot occur at all.
Modifier and Type | Method and Description |
---|---|
byte[] |
getBytes(java.lang.String string)
Returns the bytes of the given string as array encoded to the charset
this instance represents, avoiding the unnecessary exception handling
(UnsupportedEncodingException).
|
java.nio.charset.Charset |
getCharset()
Returns the corresponding charset object.
|
java.lang.String |
getName()
Returns the pure upper case encoding name (e.g.
|
java.lang.String |
newString(byte[] bytes)
Returns a new String initialized with the given bytes which are expected
to be encoded according to the character set this instance represents,
avoiding the unnecessary exception handling (UnsupportedEncodingException).
|
java.lang.String getName()
java.nio.charset.Charset getCharset()
java.lang.String newString(byte[] bytes)
It is the same like: new String(bytes, checkedCharsetName.toString());
bytes
- The byte to create a string from.byte[] getBytes(java.lang.String string)
string
- The string to be converted to a byte array using this instance's charset.