public static String removeFromEndOfString(String source,String stringToRemove){
  if (stringToRemove == null) {
    return source;
  }
  String result=source;
  if (source != null && source.endsWith(stringToRemove)) {
    result=source.substring(0,source.length() - 1);
  }
  return result;
}

public static String removeFromEndOfString ( String source , String stringToRemove ) { if ( stringToRemove == null ) { return source ; } String result = source ; if ( source != null && source . endsWith ( stringToRemove ) ) { result = source . substring ( 0 , source . length ( ) - 1 ) ; } return result ; }
remove the stringtoremove from source when existing
