Java Object to String objectToStringNoNull(Object obj)

Here you can find the source of objectToStringNoNull(Object obj)

Description

Converts an object to a string via it's toString() method.

License

Open Source License

Declaration

public static String objectToStringNoNull(Object obj) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static final String NullString = "[NULL]";

    /** Converts an object to a string via it's toString() method. If the object itself is null then "[NULL]" is returned. */
    public static String objectToStringNoNull(Object obj) {
        String msg = NullString;//from  w  ww  .  ja  v  a  2s  .  c o  m
        if (obj != null)
            msg = obj.toString();
        return msg;
    }
}

Related

  1. objectToString(Object object, String defaultValue)
  2. objectToString(Object objectStr)
  3. objectToString(Object x)
  4. ObjectToString(Object x)
  5. objectToString(Object[] obj)
  6. objToString(Object obj)
  7. objToString(Object obj)
  8. objToString(Object obj)
  9. objToString(Object[] obj)