List of utility methods to do String Pad Left
String | leftPad(String base, int length, char pad) left Pad StringBuilder sb = new StringBuilder(); for (int i = 0; i < length - base.length(); i++) { sb.append(pad); sb.append(base); return sb.toString(); |
String | leftPad(String csIn, int nRequiredLength, char cFill) left Pad String csOut = new String(); int nLgStringIn = csIn.length(); int nNbcharToPad = nRequiredLength - nLgStringIn; if (nNbcharToPad > 0) { for (int n = 0; n < nNbcharToPad; n++) { csOut = csOut + cFill; csOut = csOut + csIn; ... |
String | leftPad(String in, char padding, int length) left Pad String out = ""; int toPad = length - in.length(); if (toPad < 0) { throw new IllegalArgumentException("Input string longer than requested length"); out = getStringRepetition(padding + "", toPad) + in; return out; |
String | leftPad(String input, char padding, int length) left Pad if (nullOrEmpty(input)) input = ""; if (input.length() >= length) return input; String padString = createPad(padding, length - input.length()); return padString.concat(input); |
String | leftPad(String input, int length, char pad) Left pad a string with the specified character, if the string length is less than the specified length. if (input.length() < length) { StringBuilder sb = new StringBuilder(); for (int i = 0, len = length - input.length(); i < len; i++) { sb.append(pad); sb.append(input); return sb.toString(); return input; |
String | leftPad(String inStr, int length, char paddingChar) Left padding the string with the specified padding character upto the specified length. if (inStr.length() == length) return inStr; StringBuffer outStr = new StringBuffer(); for (int i = inStr.length(); i < length; i++) { outStr.append(paddingChar); outStr.append(inStr); return outStr.toString(); ... |
String | leftPad(String original, int length, char padChar) Pads the String with the given character until it has the given length. if (original.length() >= length) { return original; return stringOfChar(padChar, length - original.length()) + original; |
String | leftPad(String s, char paddingCharacter, int length) left Pad if (s.length() >= length) return s; StringBuffer sb = new StringBuffer(); for (int i = s.length(); i < length; i++) { sb.append(paddingCharacter); sb.append(s); return sb.toString(); ... |
String | leftPad(String s, int l) left pad the string passed to a field the size passed return blanks(l - s.length()) + s;
|
String | leftPad(String s, int len, char c) Returns a string of length len left-padded with characters c. int slen = s.length(); if (slen >= len) return s; else { char[] pad = new char[len - slen]; for (int i = len - slen - 1; i >= 0; i--) pad[i] = c; return new String(pad) + s; ... |