Java Object to String objectToString(Object obj, String defaultvalue)

Here you can find the source of objectToString(Object obj, String defaultvalue)

Description

object To String

License

Open Source License

Declaration

public static final String objectToString(Object obj, String defaultvalue) 

Method Source Code

//package com.java2s;

public class Main {

    public static final String objectToString(Object obj, String defaultvalue) {
        if (null == obj) {
            return defaultvalue;
        }/*from   w ww  . java  2 s  .  co m*/
        try {
            return obj.toString();
        } catch (Exception e) {
            return defaultvalue;
        }
    }

    public static String toString(String[] content, String sign) {
        if (null == content) {
            return null;
        }

        sign = null == sign ? "," : sign;
        StringBuilder strBuilder = new StringBuilder();
        for (int i = 0; i < content.length; i++) {
            strBuilder.append(content[i]);
            if (i < content.length - 1) {
                strBuilder.append(sign);
            }
        }

        return strBuilder.toString();
    }
}

Related

  1. objectToString(Object o, boolean quoteStrings)
  2. objectToString(Object obj)
  3. objectToString(Object obj)
  4. objectToString(Object obj)
  5. objectToString(Object obj)
  6. objectToString(Object object)
  7. objectToString(Object object, String defaultValue)
  8. objectToString(Object objectStr)
  9. objectToString(Object x)