Java String Empty to Null emptyStringToNull(String input)

Here you can find the source of emptyStringToNull(String input)

Description

empty String To Null

License

Open Source License

Declaration

public static String emptyStringToNull(String input) 

Method Source Code

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

public class Main {
    public static String emptyStringToNull(String input) {
        if (input.trim().equals("")) {
            return null;
        } else {/*w ww .  j av a2s  .c o m*/
            return input.trim();
        }
    }
}

Related

  1. emptyStringToNull(String str)
  2. emptyStringToNull(String string)
  3. emptyToDefault(String value, String def)
  4. emptyToDefault(T[] values, T[] def)