Trim String, if String is null, return null - Android java.lang

Android examples for java.lang:String Strip

Description

Trim String, if String is null, return null

Demo Code

import java.io.UnsupportedEncodingException;
import java.util.*;

public class Main{

    /**/*from   w ww.  j  ava2  s  .c  o  m*/
     * Trim String, if String is null, return null
     *
     * @param str <code>String</code>
     * @return @see java.lang.String#trim
     */
    public static String trim(String str) {
        String strReturn;
        if (str != null) {
            strReturn = str.trim();
        } else {
            strReturn = str;
        }
        return strReturn;
    }

}

Related Tutorials