Java Utililty Methods String Pad Left

List of utility methods to do String Pad Left

Description

The list of methods to do String Pad Left are organized into topic(s).

Method

StringleftPad(String s, int length)
Returns a copy of s padded with leading spaces so that it's length is length.
StringBuffer sb = new StringBuffer();
for (int i = length - s.length(); i > 0; i--)
    sb.append(" ");
sb.append(s);
return sb.toString();
StringleftPad(String s, int length)
left Pad
if (s == null)
    s = "";
if (s.length() > length)
    return s.substring(0, length);
return repeat(" ", length - s.length()) + s;
StringleftPad(String s, int minLength)
Pads the string at the left with spaces until it reaches the desired length.
return leftPad(s, minLength, ' ');
StringleftPad(String s, int n)
left Pad
return String.format("%1$#" + n + "s", s);
StringleftPad(String s, int target)
Node.js lol
return leftPad(s, target, ' ');
StringleftPad(String s, int width)
Left pad a string s to Width.
String tmp = "";
int npad = width - s.length();
if (npad < 0)
    tmp = s.substring(0, width);
else if (npad == 0)
    tmp = s;
else {
    for (int i = 0; i < npad; i++)
...
StringleftPad(String s, int z)
Left pad a String with spaces.
return leftPad(s, z, " ");
StringleftPad(String srcStr, char padChar, int destLen)
left Pad
if (srcStr == null) {
    return genStr(padChar, destLen);
} else if (srcStr.length() < destLen) {
    StringBuilder destSrc = new StringBuilder(destLen);
    destSrc.append(srcStr);
    for (int i = srcStr.length(); i < destLen; i++) {
        destSrc.insert(0, padChar);
    return destSrc.toString();
} else {
    return srcStr;
StringleftPad(String srcString, char c, int length)
left Pad
if (srcString == null) {
    srcString = "";
int tLen = srcString.length();
if (tLen >= length)
    return srcString;
int iMax = length - tLen;
StringBuilder sb = new StringBuilder();
...
StringleftPad(String srcString, char c, int length)
left Pad
if (srcString == null) {
    srcString = "";
int tLen = srcString.length();
if (tLen >= length)
    return srcString;
int iMax = length - tLen;
StringBuffer sb = new StringBuffer();
...