public static String stripEnd(final String str, final String stripChars) {
    int end;
    if (str == null || (end = str.length()) == 0) {
      return str;
    }

    if (stripChars == null) {
      while (end != 0 && Character.isWhitespace(str.charAt(end - 1))) {
        end--;
      }
    } else if (stripChars.isEmpty()) {
      return str;
    } else {
      while (end != 0 && stripChars.indexOf(str.charAt(end - 1)) != INDEX_NOT_FOUND) {
        end--;
      }
    }
    return str.substring(0, end);
  }
@Test
  public void testStripEnd() {
    assertNull(StringUtils.stripEnd(null, "ab"));
    assertEquals("", StringUtils.stripEnd("", "ab"));
    assertEquals("abc", StringUtils.stripEnd("abc", null));
    assertEquals("abc", StringUtils.stripEnd("abc  ", null));
    assertEquals("abc", StringUtils.stripEnd("abc", ""));
    assertEquals("abc", StringUtils.stripEnd("abcabab", "ab"));
  }