static public String removeFromEnd ( String s , int c ) { if ( 0 > s . indexOf ( c ) ) // none return s ; int len = s . length ( ) ; while ( ( s . charAt ( len - 1 ) == c ) && ( len > 0 ) ) len -- ; if ( len == s . length ( ) ) return s ; return s . substring ( 0 , len ) ; }
Remove all occurrences of the character c at the end of s .