public static String trimEnd( final String source, char c ) {
    if ( source == null ) {
      return null;
    }

    int index = source.length();

    while ( index > 0 && source.charAt( index - 1 ) == c ) {
      index--;
    }

    return source.substring( 0, index );
  }
@Test
  public void testTrimEnd_Many() {
    assertEquals( "/file/path", StringUtil.trimEnd( "/file/path///", '/' ) );
  }