Java String Pad Left leftPad(String targetStr, char appendChar, int length)

Here you can find the source of leftPad(String targetStr, char appendChar, int length)

Description

left Pad

License

Apache License

Declaration

public static String leftPad(String targetStr, char appendChar, int length) 

Method Source Code

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

public class Main {

    public static String leftPad(String targetStr, char appendChar, int length) {
        if (targetStr == null) {
            return null;
        }/*from w  ww .  j a v  a2 s  .  c om*/
        int len = targetStr.length();
        while (len++ < length) {
            targetStr = appendChar + targetStr;
        }
        return targetStr;
    }
}

Related

  1. leftPad(String str, int width, char padding)
  2. leftPad(String str, String character, int size)
  3. leftPad(String string, char pad, int size)
  4. leftPad(String string, int length)
  5. leftPad(String strInput, int intLength)
  6. leftPad(String text, int length, char padChar)
  7. leftPad(String text, int size)
  8. leftPad(String toPad, int numPads)
  9. leftPad(String value, int makeLength, char paddingCharacter)