Java String Empty to Null emptyToNull(String str)

Here you can find the source of emptyToNull(String str)

Description

empty To Null

License

Apache License

Declaration

public static String emptyToNull(String str) 

Method Source Code

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

public class Main {

    public static String emptyToNull(String str) {
        return isBlank(str) ? null : str;
    }/*from  w ww  . j  av a  2 s.  c o m*/

    public static boolean isBlank(String str) {
        return str == null || str.trim().length() == 0;
    }

    public static String trim(String str) {
        return (null == str) ? null : str.trim();
    }
}

Related

  1. emptyToNull(final String text, final boolean doTrim)
  2. emptyToNull(String field)
  3. emptyToNull(String s)
  4. emptyToNull(String s)
  5. emptyToNull(String str)
  6. emptyToNull(String str)
  7. emptyToNull(String string)
  8. emptyToNull(String text)
  9. emptyToNull(String val)