List of utility methods to do String Pad Left
String | lpad(int value, int padLen, char padChar) Returns value argument, left-padded to length padLen argument with the sequence of character in padChar argument. return lpad(String.valueOf(value), padLen, padChar);
|
String | lpad(Object str, int len, String padding) Lpad. StringBuilder sb = new StringBuilder(); for (int i = 0; i < len - str.toString().length(); i++) { sb.append(padding); sb.append(str); return sb.toString(); |
String | lpad(String base, int len, String pad) Returns the string str left-padded with the string pad to a length of len characters. if (len < 0) { return null; } else if (len == 0) { return ""; char[] data = new char[len]; char[] baseChars = base.toCharArray(); char[] padChars = pad.toCharArray(); ... |
String | lpad(String input, char padding, int length) Padds the string to the left with the given character for the specified length. if (input == null) { input = new String(); if (input.length() >= length) { return input; } else { StringBuffer result = new StringBuffer(); int numChars = length - input.length(); ... |
String | lpad(String input, int length) Left Pads the input String with spaces to take up a specified length NOTE: The input will be truncated if it exceeds the specified length. return lpad(input, length, ' '); |
String | lpad(String input, String padChar, int finalLength) lpad StringBuffer out = new StringBuffer(input); int currentLength = out.length(); while (currentLength < finalLength) { out.insert(0, padChar.subSequence(0, Math.min(padChar.length(), finalLength - currentLength))); currentLength = out.length(); return out.toString(); |
String | lPad(String input, String replace, int length) l Pad String format = "%" + length + "s"; return String.format(format, input).replace(" ", replace); |
String | lpad(String s, char addChar, int length) lpad StringBuffer val = new StringBuffer(); int currLength = s.length(); for (int i = currLength; i < length; i++) { val.append(addChar); return val.append(s).toString(); |
String | lpad(String s, int len, char ch) Pads a string to the desired length. if (s == null || s.length() >= len) return s; StringBuffer buf = new StringBuffer(len); for (len -= s.length(); len > 0; len--) buf.append(ch); buf.append(s); return buf.toString(); |
String | lpad(String s, int len, String padc) lpad int slen = 0; if (s != null) { slen = s.length(); if (slen >= len) { return s; StringBuilder sb = new StringBuilder(s); ... |