StringUtils.isBlank


  • This function returns true if the string contains null,empty or whiteSpace.Where as isEmpty returns true for null & empty.
  • This function is null safe
  • You can use this method with the help of commons-lang-2.6.jar.
  • You can download this jar by using the below link


     http://mvnrepository.com/artifact/commons-lang/commons-lang/2.6

  1. package com.utilitySample;
  2. import org.apache.commons.lang.StringUtils;

  3.  public class StringUtility {
  4. public static void main(String[] args) {
  5.                  System.out.println(StringUtils.isBlank(null));
  6. System.out.println(StringUtils.isBlank(""));
  7. System.out.println(StringUtils.isBlank(" "));
  8. System.out.println(StringUtils.isBlank("vel"));
  9. System.out.println(StringUtils.isBlank("  vel "));
  10.    }
  11.  }
 Output : 

  true
  true
  true
  false
  false

No comments:

Post a Comment