List of utility methods to do String Chop Right
String | chopFromRight(String text, char character, int count) Chop the string off up to the last occurrence of character. String target = text; int inTotal = countOf(character, text); if (inTotal > count && count > 0) { int total = (inTotal - count) + 1; int indexFrom = 0; int nextIndex = 0; while (total > 0) { nextIndex = text.indexOf(character, indexFrom); ... |
String | chopRight(String str, char delimiter) chop Right if (str == null || "".equals(str)) { return str; int pos; for (pos = str.length() - 1; pos >= 0; pos--) { if (str.charAt(pos) != delimiter) { break; return str.substring(0, pos + 1); |