public static String removeEnd(final String s, final String remove) {
    """
	<p>
	Removes a substring only if it is at the end of a source string,
	otherwise returns the source string.
	</p>
	
	<p>
	A {@code null} source string will return {@code null}. An empty ("")
	source string will return the empty string. A {@code null} search string
	will return the source string.
	</p>
	
	<pre>
	StringUtils.removeEnd(null, *)      = null
	StringUtils.removeEnd("", *)        = ""
	StringUtils.removeEnd(*, null)      = *
	StringUtils.removeEnd("www.domain.com", ".com.")  = "www.domain.com"
	StringUtils.removeEnd("www.domain.com", ".com")   = "www.domain"
	StringUtils.removeEnd("www.domain.com", "domain") = "www.domain.com"
	StringUtils.removeEnd("abc", "")    = "abc"
	</pre>
    """
        if (isEmpty(s) || isEmpty(remove)) {
            return s;
        }
        if (s.endsWith(remove)) {
            return s.substring(0, s.length() - remove.length());
        }
        return s;
    }
public static String removeEnd(final String s, final String remove) {
        if (isEmpty(s) || isEmpty(remove)) {
            return s;
        }
        if (s.endsWith(remove)) {
            return s.substring(0, s.length() - remove.length());
        }
        return s;
    }
public static String removeEnd ( final String s , final String remove ) { if ( isEmpty ( s ) || isEmpty ( remove ) ) { return s ; } if ( s . endsWith ( remove ) ) { return s . substring ( 0 , s . length ( ) - remove . length ( ) ) ; } return s ; }
<p>
Removes a substring only if it is at the end of a source string,
otherwise returns the source string.
</p>

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

<pre>
StringUtils.removeEnd(null, *)      = null
StringUtils.removeEnd("", *)        = ""
StringUtils.removeEnd(*, null)      = *
StringUtils.removeEnd("www.domain.com", ".com.")  = "www.domain.com"
StringUtils.removeEnd("www.domain.com", ".com")   = "www.domain"
StringUtils.removeEnd("www.domain.com", "domain") = "www.domain.com"
StringUtils.removeEnd("abc", "")    = "abc"
</pre>
<p > Removes a substring only if it is at the end of a source string otherwise returns the source string . < / p >