Android Utililty Methods String Pad from Left

List of utility methods to do String Pad from Left

Description

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

Method

Stringlpad(String str, int length)
lpad
if (isBlank(str))
    return "";
int j = str.length();
for (int i = j; i < length; i++) {
    str = "0" + str;
return str;
Stringpadding(int width)
Returns space padding
if (width < 0)
    throw new IllegalArgumentException("width must be > 0");
if (width < padding.length)
    return padding[width];
char[] out = new char[width];
for (int i = 0; i < width; i++)
    out[i] = ' ';
return String.valueOf(out);
...
StringpadLeft(String input, int size)
Pad the specified number of spaces to the input string to make it that length
if (input.length() > size) {
    throw new IllegalArgumentException(
            "input must be shorter than or equal to the number of spaces: "
                    + size);
StringBuilder sb = new StringBuilder();
for (int i = input.length(); i < size; i++) {
    sb.append(" ");
...
StringprefixPad(String toPad, String padLetter, int targetLength)
prefix Pad
if (toPad == null)
    toPad = "";
while (toPad.length() < targetLength) {
    toPad = padLetter + toPad;
return toPad;