public static String removeTrailing ( String string , char c ) { if ( string == null ) { return null ; } final int lastCharIndex = string . length ( ) - 1 ; return string . charAt ( lastCharIndex ) == c ? string . substring ( 0 , lastCharIndex ) : string ; }
Remove trailing character if exists .