List of utility methods to do String Pad Left
String | lpad(String s, int length, char pad) lpad if (s == null || s.length() >= length) { return s; StringBuilder result = new StringBuilder(length); int padSize = length - s.length(); while (padSize > 0) { result.append(pad); padSize--; ... |
String | lpad(String s, int width) Left pad string with blanks to specified width. if (s.length() < width) { return dupl(' ', width - s.length()) + s; } else { return s; |
String | lpad(String s, String fill, int len) lpad if (s == null || fill == null || s.length() >= len || fill.length() == 0) { return s; StringBuffer buf = new StringBuffer(s); while (buf.length() < len) { buf.insert(0, fill); return buf.substring(buf.length() - len, buf.length()); ... |
String | lpad(String src, int length, char padding) lpad if (src == null) { src = ""; while (src.length() < length) { src = padding + src; return src; |
String | lpad(String str, char pad, int len) lpad while (str.length() < len) { str = pad + "" + str; return str; |
String | lPad(String str, int len, char pad) l Pad return lPad(str, len, pad, false);
|
String | lpad(String str, int len, char padding) lpad if (len < str.length()) { return str.substring(str.length() - len); } else { StringBuffer buf = new StringBuffer(len); int gap = len - str.length(); for (int i = 0; i < gap; i++) { buf.insert(i, padding); buf.insert(gap, str); return buf.toString(); |
String | LPad(String str, int length, String chr) L Pad StringBuilder sb = new StringBuilder(str); while (sb.length() < length) sb.insert(0, chr); return sb.toString(); |
String | lPad(String str, int length, String padString) To pad the given string with a user specified character on the left up to the given length. int lOriginal = str.length(); int lPadStr = padString.length(); int times2Pad = 0; int lPadded = 0; if (lOriginal >= length) return str; StringBuffer sb = new StringBuffer(); String padded; ... |
String | lpad(String str, int size) lpad if (str.length() >= size) return str; String pad = ""; int nbBlanks = size - str.length(); for (int i = 0; i < nbBlanks; i++) pad += " "; return pad + str; |