class Const {

  public static String rtrim( String source ) {
    if ( source == null ) {
      return null;
    }

    int max = source.length();
    while ( max > 0 && isSpace( source.charAt( max - 1 ) ) ) {
      max--;
    }

    return source.substring( 0, max );
  }

}