Friday, 17 April 2015

StringUtils.isNotBlank() VS StringUtils.isNotEmpty() in Java

  StringUtils.isNotBlank() VS StringUtils.isNotEmpty() in Java



isNotBlank



public static boolean isNotBlank(String str)

    Checks if a String is not empty (""), not null and not whitespace only.

    

    StringUtils.isNotBlank(null) = false

    StringUtils.isNotBlank("") = false

     StringUtils.isNotBlank(" ") = false

     StringUtils.isNotBlank("java") = true

    StringUtils.isNotBlank("java  ") = true

    

    Parameters:

    str - the String to check

    Returns:true if the String is not empty and not null and not whitespace
        
        
        



isNotEmpty

public static boolean isNotEmpty(String str)

    Checks if a String is not empty ("") and not null.

     StringUtils.isNotEmpty(null)      = false
     StringUtils.isNotEmpty("")        = false
     StringUtils.isNotEmpty(" ")       = true
     StringUtils.isNotEmpty("java")     = true
     StringUtils.isNotEmpty("java  ") = true
    




    Parameters:
        str - the String to check, may be null

    Returns:
        true if the String is not empty and not null



Related Post:





No comments:

Post a Comment