Java Utililty Methods UTF8 Convert To

List of utility methods to do UTF8 Convert To

Description

The list of methods to do UTF8 Convert To are organized into topic(s).

Method

StringfromUTF8(byte[] b)
from UTF
try {
    return new String(b, "UTF-8");
} catch (UnsupportedEncodingException e) {
    throw new IllegalStateException("can't happen");
StringfromUTF8(byte[] bytes)
from UTF
try {
    return new String(bytes, utf8);
} catch (UnsupportedEncodingException e) {
    throw new RuntimeException(e);
StringfromUTF8(byte[] bytes)
Convert from UTF-8 bytes to a String.
if (bytes == null) {
    return null;
try {
    return new String(bytes, UTF_8_ENCODING);
} catch (UnsupportedEncodingException e) {
    throw new IllegalStateException("UTF-8 not supported?", e);
StringfromUTF8(byte[] bytes)
Converts the passed byte array to a string, using UTF-8 encoding, and turning the checked exception (which should never happen) into a runtime exception.
try {
    if (bytes == null)
        return "";
    return new String(bytes, "UTF-8");
} catch (UnsupportedEncodingException e) {
    throw new RuntimeException("UTF-8 not supported", e);
StringfromUTF8Bytes(byte[] bytes)
from UTF Bytes
return fromBytes(bytes, CHARSET_UTF_8);
StringfromUTF8Bytes(byte[] bytes)
from UTF Bytes
if (bytes == null) {
    return null;
String str = null;
try {
    str = new String(bytes, "UTF-8");
} catch (UnsupportedEncodingException e) {
return str;
byte[]getBytesUtf8(String str)
get Bytes Utf
if (has_utf8) {
    try {
        return str.getBytes("UTF-8");
    } catch (UnsupportedEncodingException usx) {
char[] chars = str.toCharArray();
int vlen = chars.length;
...
byte[]getBytesUtf8(String string)
Encodes the given string into a sequence of bytes using the UTF-8 charset, storing the result into a new byte array.
if (string == null) {
    return null;
try {
    return string.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
    throw new IllegalStateException("UTF-8 : " + e);
byte[]getBytesUtf8(String string)
Encodes the given string into a sequence of bytes using the UTF-8 charset, storing the result into a new byte array.
try {
    return string == null ? null : string.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
return null;
byte[]getBytesUTF8(String string)
Get bytes by input.getBytes("UTF-8") .
if (string == null) {
    return null;
try {
    return string.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
    return null;