List of utility methods to do String Pad
String | toPaddedString(String source, int length, char pad, boolean trailing) to Padded String int len = source.length(); if (len >= length) { return source; StringBuffer sb = new StringBuffer(length); if (trailing) { sb.append(source); for (int i = len; i < length; i++) { sb.append(pad); if (!trailing) { sb.append(source); return sb.toString(); |
String | toPaddedString(String source, int length, String pad, boolean trailing) to Padded String int len = source.length(); if (len == length) { return source; if (len > length) { if (trailing) { return source.substring(0, length); } else { ... |
String | padLeft(String str, char padding, int upTo) Pad a string on the left until it reaches the designated height StringBuilder stringBuilder = new StringBuilder(str); while (stringBuilder.length() < upTo) { stringBuilder.insert(0, padding); return stringBuilder.toString(); |
String | padString(String source) pad String char paddingChar = ' '; int size = 16; int x = source.length() % size; int padLength = size - x; for (int i = 0; i < padLength; i++) { source += paddingChar; return source; ... |