public static String substringBeforeLast(String str, String separator) {
        if (isEmpty(str) || isEmpty(separator)) {
            return str;
        }
        int pos = str.lastIndexOf(separator);
        if (pos == INDEX_NOT_FOUND) {
            return str;
        }
        return str.substring(0, pos);
    }
<p>Gets the substring before the last occurrence of a separator.
The separator is not returned.</p>

<p>A {@code null} string input will return {@code null}.
An empty ("") string input will return the empty string.
An empty or {@code null} separator will return the input string.</p>

<p>If nothing is found, the string input is returned.</p>

<pre>
StringUtils.substringBeforeLast(null, *)      = null
StringUtils.substringBeforeLast("", *)        = ""
StringUtils.substringBeforeLast("abcba", "b") = "abc"
StringUtils.substringBeforeLast("abc", "c")   = "ab"
StringUtils.substringBeforeLast("a", "a")     = ""
StringUtils.substringBeforeLast("a", "z")     = "a"
StringUtils.substringBeforeLast("a", null)    = "a"
StringUtils.substringBeforeLast("a", "")      = "a"
</pre>

@param str  the String to get a substring from, may be null
@param separator  the String to search for, may be null
@return the substring before the last occurrence of the separator,
 {@code null} if null String input
@since 2.0
android/android_framework/base/src/main/java/lang3/StringUtils.java