public static String trim(String str) {
        return str == null ? null : str.trim();
    }
<p>Removes control characters (char &lt;= 32) from both
ends of this String, handling {@code null} by returning
{@code null}.</p>

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

<p>To trim your choice of characters, use the
{@link #strip(String, String)} methods.</p>

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

@param str  the String to be trimmed, may be null
@return the trimmed string, {@code null} if null String input
android/android_framework/base/src/main/java/lang3/StringUtils.java