List of utility methods to do String Pad Left
String | leftPad(String str, String character, int size) left Pad if (str != null) { int delta = size - str.length(); for (int i = 0; i < delta; i++) { str = character + str; return str; |
String | leftPad(String string, char pad, int size) Return the padded left of a string by padding character. if (string == null || size < 0) { return null; } else if (string.length() == 0 || size == 0) { return ""; StringBuilder sb = new StringBuilder(); for (int i = 0; i < size; i++) { sb.append(pad); ... |
String | leftPad(String string, int length) left Pad return leftPad(string, length, ' '); |
String | leftPad(String strInput, int intLength) Pad " " to string left side return leftPad(strInput, intLength, ' '); |
String | leftPad(String targetStr, char appendChar, int length) left Pad if (targetStr == null) { return null; int len = targetStr.length(); while (len++ < length) { targetStr = appendChar + targetStr; return targetStr; ... |
String | leftPad(String text, int length, char padChar) left Pad String text2 = text; if (text2.length() < length) { StringBuffer buf = new StringBuffer(""); for (int i = text2.length(); i < length; i++) { buf.append(padChar); buf.append(text2); text2 = buf.toString(); ... |
String | leftPad(String text, int size) Pad some text on the left (i.e., right-align it) until it's a specified width. int numSpaces = size - text.length(); if (numSpaces <= 0) return text; StringBuffer buf = new StringBuffer(size); for (int i = 0; i < numSpaces; i++) buf.append(' '); for (int i = numSpaces; i < size; i++) buf.append(text.charAt(i - numSpaces)); ... |
String | leftPad(String toPad, int numPads) left Pad return leftPad(toPad, numPads, " "); |
String | leftPad(String value, int makeLength, char paddingCharacter) left Pad if (makeLength <= 0) { throw new IllegalArgumentException("Pad length MUST be over zero"); StringBuffer buffer = new StringBuffer(); buffer.append(buildString(paddingCharacter, makeLength - value.length())); buffer.append(value); return buffer.toString(); |
String | leftPad(String value, int size, String pad) Adds pad on the left side to complete the size if (value.length() < size && !pad.isEmpty()) { return leftPad(pad.concat(value), size, pad); return value; |