Android String Empty Check toNullIfEmpty(String string)

Here you can find the source of toNullIfEmpty(String string)


Old location of Strings#emptyToNull ; this method will be deprecated soon.


Apache License


public static String toNullIfEmpty(String string) 

Method Source Code

/*/* ww  w.  j  a v  a  2s  .  co  m*/
  * Copyright (C) 2000 Google Inc.
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.

import static;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{
      * Old location of {@link Strings#emptyToNull}; this method will be
      * deprecated soon.
     public static String toNullIfEmpty(String string) {
         return Strings.emptyToNull(string);


  1. isNotEmpty(String s)
  2. isEmpty(String string)
  3. isEmptyString(String s)
  4. isEmptyOrNull(String str)
  5. toNullIfEmptyOrWhitespace(String string)
  6. isNullOrEmptyOrOnlyWhitespaces(String string)
  7. nullToEmpty(String url)
  8. isEmpty(String s)
  9. isEmpty(String s)