List of utility methods to do Array Chomp
String | chomp(char[] charArray) Given a character array, this method constructs a new string without trailing carriage return or newline characters. int length = charArray.length; int endIndex = charArray.length - 1; for (int i = endIndex; i > -1; i--) { if (charArray[i] == '\r' || charArray[i] == '\n') { length--; } else { break; return new String(charArray, 0, length); |
char[] | chompArray(char[] array, int start, int end) chomp Array char[] newArray = new char[end - start]; for (int i = 0, j = start; j < end; i++, j++) { newArray[i] = array[j]; return newArray; |