Java Null Value Convert convertNull(Object o)

Here you can find the source of convertNull(Object o)

Description

convert Null

License

Apache License

Declaration

public static String convertNull(Object o)
  

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static String convertNull(String strvalue) {
        try {//from w w w  . ja  v  a  2 s. c o  m
            if (strvalue.equals("null") || strvalue.length() == 0) {
                return "";
            } else {
                return strvalue.trim();
            }
        } catch (Exception e) {
            return "";
        }
    }

    public static String[] convertNull(String[] aContent) {
        try {
            for (int i = 0; i < aContent.length; i++) {
                if (aContent[i].toLowerCase().compareTo("null") == 0) {
                    aContent[i] = "";
                }
            }
            return aContent;
        } catch (Exception e) {
            return null;
        }
    }

    public static String convertNull(Object o) {
        try {
            String strvalue = String.valueOf(o);
            if (strvalue.equals(null) || strvalue.equals("null") || strvalue.length() == 0) {
                return "";
            } else {
                return strvalue.trim();
            }
        } catch (Exception e) {
            return "";
        }
    }
}

Related

  1. convertNull(Object source)
  2. convertNull2ZeroString(String value)
  3. convertNullableString(Object object)
  4. convertNullString2Empty(Object str)