Java String Empty to Null emptyToNull(String str)

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

Description

empty To Null

License

Open Source License

Declaration

public static String emptyToNull(String str) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String emptyToNull(String str) {
        return isEmpty(str) ? null : str;
    }//  w w w.j  a va 2 s  .c om

    public static boolean isEmpty(String str) {
        return (str == null || "".equals(str.trim()));
    }

    public static boolean equals(String str1, String str2) {
        if (str1 != null && str1 != null) {
            return str1.equals(str2);
        } else if (str1 == null && str2 == null) {
            return true;
        } else {
            return false;
        }
    }
}

Related

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