public static String trimToNull(String str) {
        String ts = trim(str);
        return isEmpty(ts) ? null : ts;
    }
<p>Removes control characters (char &lt;= 32) from both
ends of this String returning {@code null} if the String is
empty ("") after the trim or if it is {@code null}.

<p>The String is trimmed using {@link String#trim()}.
Trim removes start and end characters &lt;= 32.
To strip whitespace use {@link #stripToNull(String)}.</p>

<pre>
StringUtils.trimToNull(null)          = null
StringUtils.trimToNull("")            = null
StringUtils.trimToNull("     ")       = null
StringUtils.trimToNull("abc")         = "abc"
StringUtils.trimToNull("    abc    ") = "abc"
</pre>

@param str  the String to be trimmed, may be null
@return the trimmed String,
 {@code null} if only chars &lt;= 32, empty or null String input
@since 2.0
android/android_framework/base/src/main/java/lang3/StringUtils.java