Java String Pad Left lpad(String s, char addChar, int length)

Here you can find the source of lpad(String s, char addChar, int length)

Description

lpad

License

Apache License

Declaration

public static String lpad(String s, char addChar, int length) 

Method Source Code

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

public class Main {

    public static String lpad(String s, char addChar, int length) {
        StringBuffer val = new StringBuffer();
        int currLength = s.length();
        for (int i = currLength; i < length; i++) {
            val.append(addChar);
        }//  w  ww  .  ja v a  2 s . com
        return val.append(s).toString();
    }
}

Related

  1. lpad(String base, int len, String pad)
  2. lpad(String input, char padding, int length)
  3. lpad(String input, int length)
  4. lpad(String input, String padChar, int finalLength)
  5. lPad(String input, String replace, int length)
  6. lpad(String s, int len, char ch)
  7. lpad(String s, int len, String padc)
  8. lpad(String s, int length, char pad)
  9. lpad(String s, int width)