Java Utililty Methods Object to String

List of utility methods to do Object to String

Description

The list of methods to do Object to String are organized into topic(s).

Method

StringtoString(Object val)
to String
if (val == null) {
    return null;
if (val.getClass().isArray()) {
    return Arrays.deepToString((Object[]) val);
if (Collection.class.isAssignableFrom(val.getClass())) {
    return val.toString();
...
StringtoString(Object value)
Deals with primitive arrays
if (value == null)
    return null;
if (value instanceof short[]) {
    return Arrays.toString((short[]) value);
} else if (value instanceof int[]) {
    return Arrays.toString((int[]) value);
} else if (value instanceof long[]) {
    return Arrays.toString((long[]) value);
...
StringtoString(Object value)
to String
if (value instanceof Map)
    return mapToString((Map<String, Object>) value);
else if (value instanceof List)
    return listToString((List<Object>) value);
else if (value == null)
    return "null";
else
    return value.toString().trim();
...
StringtoString(Object value)
to String
if (value == null)
    return null;
if (value.getClass().isArray()) {
    if (value instanceof boolean[]) {
        return Arrays.toString((boolean[]) value);
    } else if (value instanceof byte[]) {
        return Arrays.toString((byte[]) value);
    } else if (value instanceof short[]) {
...
StringtoText(Object[] objs, String ch)
to Text
StringBuffer text = new StringBuffer();
for (Object o : objs) {
    text.append(o.toString());
    text.append(ch);
String t = text.toString().trim();
if (t.endsWith(ch)) {
    t = t.substring(0, t.length() - 1);
...
StringtoText(T t)
Converts an enum to basic text representation
return t.toString().replaceAll("_+", " ").toLowerCase();