/** * Trim all occurences of the supplied leading character from the given String. * * @param str the string to check * @param checker the character checker * @return the trimmed String */ public static String trimLeadingCharacter(String str, CharacterFilter checker) { if (hasLength(str) == false) { return str; } if (checker == null) throw new IllegalArgumentException("Null character checker"); StringBuffer buf = new StringBuffer(str); while (buf.length() > 0 && checker.isCharacterLegal(buf.charAt(0))) { buf.deleteCharAt(0); } return buf.toString(); }