Java Utililty Methods String Empty to Null

List of utility methods to do String Empty to Null

  1. HOME
  2. Java
  3. S
  4. String Empty to Null

Description

The list of methods to do String Empty to Null are organized into topic(s).

Method

String emptyStringToNull(String input)
empty String To Null
if (input.trim().equals("")) {
 return null;
} else {
 return input.trim();
String emptyStringToNull(String str)
empty String To Null
return str == null || str.equals("") ? null : str;
String emptyStringToNull(String string)
Returns null, if the specified string is null or the empty string.
return isEmptyOrNull(string) ? null : string;
String emptyToDefault(String value, String def)
empty To Default
return (value == null || value.length() == 0) ? def : value;
T[] emptyToDefault(T[] values, T[] def)
empty To Default
return values == null || values.length == 0 ? def : values;
String emptyToNull(final String text, final boolean doTrim)
Returns null if a string variable is empty.
if (doTrim && (text != null)) {
 return ("".equals(text.trim())) ? null : text;
} else {
 return ("".equals(text)) ? null : text;
String emptyToNull(String field)
empty To Null
return "".equals(field) ? null : field;
String emptyToNull(String s)
empty To Null
if (s == null || s.length() == 0)
 return null;
String trimmed = trim(s);
return (trimmed.length() != 0 ? s : null);
String emptyToNull(String s)
Converts a 0-length string to null, leaves the string as is otherwise.
if (s == null)
 return null;
return s.length() == 0 ? null : s;
String emptyToNull(String str)
Returns the given string if it is nonempty; null otherwise.
return (str == null || str.length() == 0) ? null : str;


AltStyle によって変換されたページ (->オリジナル) /