List of utility methods to do String Pad Left
String | leftPad(String str, int size) left Pad return leftPad(str, size, ' '); |
String | leftPad(String str, int size) left Pad return leftPad(str, size, ' '); |
String | leftPad(String str, int size) Left pad a String with spaces. return leftPad(str, size, SPACE);
|
String | leftPad(String str, int size) left Pad return leftPad(str, size, ' '); |
String | leftPad(String str, int size, char padChar) left Pad String _return = str; while (_return.length() < size) { _return = padChar + _return; return _return; |
String | leftPad(String str, int size, String delim) left Pad size = (size - str.length()) / delim.length(); if (size > 0) { str = repeat(delim, size) + str; return str; |
String | leftPad(String str, int size, String padStr) Left pad a String with a specified String. Pad to a size of size . StringUtils.leftPad(null, *, *) = null StringUtils.leftPad("", 3, "z") = "zzz" StringUtils.leftPad("bat", 3, "yz") = "bat" StringUtils.leftPad("bat", 5, "yz") = "yzbat" StringUtils.leftPad("bat", 8, "yz") = "yzyzybat" StringUtils.leftPad("bat", 1, "yz") = "bat" StringUtils.leftPad("bat", -1, "yz") = "bat" StringUtils.leftPad("bat", 5, null) = " bat" StringUtils.leftPad("bat", 5, "") = " bat" if (str == null) { return null; if (isEmpty(padStr)) { padStr = " "; int padLen = padStr.length(); int strLen = str.length(); ... |
String | leftPad(String str, int size, String padStr) Left pad a String with a specified String. Pad to a size of StringUtils.leftPad(null, *, *) = null StringUtils.leftPad("", 3, "z") = "zzz" StringUtils.leftPad("bat", 3, "yz") = "bat" StringUtils.leftPad("bat", 5, "yz") = "yzbat" StringUtils.leftPad("bat", 8, "yz") = "yzyzybat" StringUtils.leftPad("bat", 1, "yz") = "bat" StringUtils.leftPad("bat", -1, "yz") = "bat" StringUtils.leftPad("bat", 5, null) = " bat" StringUtils.leftPad("bat", 5, "") = " bat" if (str == null) { return null; if (isEmpty(padStr)) { padStr = " "; int padLen = padStr.length(); int strLen = str.length(); ... |
String | leftPad(String str, int width, char c) left Pad int len = str.length(); if (width <= len) return str; int pad = width - len; StringBuffer buf = new StringBuffer(width); for (int i = 0; i < pad; ++i) buf.append(c); buf.append(str); ... |
String | leftPad(String str, int width, char padding) left Pad StringBuilder buff = new StringBuilder(); for (int i = 0; i < width; ++i) { buff.append(padding); buff.append(str); return buff.substring(buff.length() - width); |