Java Object to String objToString(Object obj)

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

Description

obj To String

License

Open Source License

Declaration

public static String objToString(Object obj) 

Method Source Code

//package com.java2s;
/**//from w w w.j a  v  a 2 s . c  o  m
  * Copyright 2010 ZTEsoft Inc. All Rights Reserved.
  *
  * This software is the proprietary information of ZTEsoft Inc.
  * Use is subject to license terms.
  * 
  * $Tracker List
  * 
  * $TaskId: $ $Date: 9:24:36 AM (May 9, 2008) $comments: create 
  * $TaskId: $ $Date: 3:56:36 PM (SEP 13, 2010) $comments: upgrade jvm to jvm1.5 
  *  
  *  
  */

public class Main {

    public static String objToString(Object obj) {
        return obj == null ? "" : obj.toString();
    }

    public static String toString(Object val) {
        if (val == null) {
            return "";
        }
        return val.toString();
    }

    public static String toString(Object[] objs) {
        if (objs != null && objs.length > 0) {
            StringBuffer buff = new StringBuffer();
            for (int i = 0; i < objs.length; i++) {
                buff.append("\nItem[").append(i).append("]\n").append(objs[i]);
            }
            return buff.toString();
        } else {
            return "";
        }
    }

    public static String toString(int val) {
        return Integer.toString(val);
    }

    public static String toString(float val) {
        return Float.toString(val);
    }

    public static String toString(double val) {
        return Double.toString(val);
    }

    public static String toString(long val) {
        return Long.toString(val);
    }

    public static String toString(short val) {
        return Short.toString(val);
    }

    public static String toString(boolean val) {
        return Boolean.toString(val);
    }
}

Related

  1. objectToString(Object objectStr)
  2. ObjectToString(Object x)
  3. objectToString(Object x)
  4. objectToString(Object[] obj)
  5. objectToStringNoNull(Object obj)
  6. objToString(Object obj)
  7. objToString(Object obj)
  8. objToString(Object[] obj)
  9. toString(Object o)