Java String Pad Left leftPad(String base, int length, char pad)

Here you can find the source of leftPad(String base, int length, char pad)

Description

left Pad

License

Apache License

Declaration

public static String leftPad(String base, int length, char pad) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String leftPad(String base, int length, char pad) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length - base.length(); i++) {
            sb.append(pad);/*from   ww w  .  j a v  a 2 s.c  o m*/
        }
        sb.append(base);
        return sb.toString();
    }
}

Related

  1. leftPad(final String value, final int length, final char paddingChar)
  2. leftPad(long value, char padChar, int maxDigits, StringBuilder buf)
  3. leftPad(Object obj, char pad, int len)
  4. leftPad(String _str, int _size, char _padChar)
  5. leftPad(String aStr, int aLen)
  6. leftPad(String csIn, int nRequiredLength, char cFill)
  7. leftPad(String in, char padding, int length)
  8. leftPad(String input, char padding, int length)
  9. leftPad(String input, int length, char pad)