Java String Pad Left lPad(String val, int length, String padChar)

Here you can find the source of lPad(String val, int length, String padChar)

Description

l Pad

License

Open Source License

Declaration

public static String lPad(String val, int length, String padChar) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String lPad(String val, int length, String padChar) {
        if (val == null)
            return null;
        int len = val.length();
        StringBuffer pad = new StringBuffer("");
        if (length > len) {
            for (int i = 1; i <= length - len; i++)
                pad.append(padChar);// w  ww .j  a v a  2  s . com
            return pad.toString() + val;
        }
        return val;
    }
}

Related

  1. lpad(String str, int size)
  2. lpad(String str, int totalPadAmount, String padChar)
  3. lpad(String str, String chr, int length)
  4. lPad(String string, char[] padding, int length)
  5. lPad(String target, String fix, int length)
  6. lpadding(String s, int n, String padding)
  7. lpadSapce(final String src, final int length)
  8. lpadWithCount(String input, String str, int count)