Java Null Value Convert convertNullString2Empty(Object str)

Here you can find the source of convertNullString2Empty(Object str)

Description

Return empty string if the input string is null

License

Open Source License

Parameter

Parameter Description
str - input string

Return

- converted string

Declaration

public static String convertNullString2Empty(Object str) 

Method Source Code

//package com.java2s;
/**//from   w w w.  ja va  2s .  c  o  m
 * Copyright 2003, 2004  ONCE Corporation
 *
 * LICENSE:
 * This file is part of BuilditMPI. It may be redistributed and/or modified
 * under the terms of the Common Public License, version 1.0.
 * You should have received a copy of the Common Public License along with this
 * software. See LICENSE.txt for details. Otherwise, you may find it online at:
 *   http://www.oncecorp.com/CPL10/ or http://opensource.org/licenses/cpl.php
 *
 * DISCLAIMER OF WARRANTIES AND LIABILITY:
 * THE SOFTWARE IS PROVIDED "AS IS".  THE AUTHOR MAKES NO REPRESENTATIONS OR
 * WARRANTIES, EITHER EXPRESS OR IMPLIED.  TO THE EXTENT NOT PROHIBITED BY LAW,
 * IN NO EVENT WILL THE AUTHOR BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT
 * LIMITATION, LOST REVENUE, PROFITS OR DATA, OR FOR SPECIAL, INDIRECT,
 * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS
 * OF THE THEORY OF LIABILITY, ARISING OUT OF OR RELATED TO ANY FURNISHING,
 * PRACTICING, MODIFYING OR ANY USE OF THE SOFTWARE, EVEN IF THE AUTHOR HAVE
 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
 *
 * -----------------------------------------------------
 * $Id$
 */

public class Main {
    /**
     * Return empty string if the input string is null
     * @param str - input string
     * @return - converted string
     */
    public static String convertNullString2Empty(Object str) {
        if (str == null)
            return "";
        else
            return str.toString();
    }
}

Related

  1. convertNull(Object o)
  2. convertNull(Object source)
  3. convertNull2ZeroString(String value)
  4. convertNullableString(Object object)
  5. convertNullToBlank(String s)
  6. convertNullToEmptyStr(String inObj)
  7. convertNullToEmptyString(Object raw)
  8. convertNullToEmptyString(String s)