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

StringobjectToString(Object obj, String defaultvalue)
object To String
if (null == obj) {
    return defaultvalue;
try {
    return obj.toString();
} catch (Exception e) {
    return defaultvalue;
StringobjectToString(Object object)
object To String
if (object != null) {
    if (object instanceof String)
        return (String) object;
    else
        return object.toString();
} else
    return null;
StringobjectToString(Object object, String defaultValue)
Gives a default value if the object is null.
return object == null ? defaultValue : String.valueOf(object);
StringobjectToString(Object objectStr)
object To String
if (objectStr == null)
    objectStr = "";
if ("null".equalsIgnoreCase(String.valueOf(objectStr)))
    objectStr = "";
return String.valueOf(objectStr);
StringObjectToString(Object x)
Object To String
return x.toString();
StringobjectToString(Object x)
object To String
String s;
return (x == null || (s = x.toString()) == null) ? "null" : s;
StringobjectToString(Object[] obj)
object To String
if (obj == null) {
    return "";
StringBuffer sb = new StringBuffer();
for (int i = 0; i < obj.length; i++) {
    if (obj[i] == null) {
        sb.append("null,");
        continue;
...
StringobjectToStringNoNull(Object obj)
Converts an object to a string via it's toString() method.
String msg = NullString;
if (obj != null)
    msg = obj.toString();
return msg;
StringobjToString(Object obj)
obj To String
return obj == null ? "" : obj.toString();
StringobjToString(Object obj)
obj To String
String result = "";
try {
    result = obj.toString();
} catch (Exception e) {
    result = null;
return result;