Java String Pad Left leftPad(String s, char paddingCharacter, int length)

Here you can find the source of leftPad(String s, char paddingCharacter, int length)

Description

left Pad

License

Open Source License

Declaration

public static String leftPad(String s, char paddingCharacter, int length) 

Method Source Code

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

public class Main {
    public static String leftPad(String s, char paddingCharacter, int length) {
        if (s.length() >= length)
            return s;
        StringBuffer sb = new StringBuffer();
        for (int i = s.length(); i < length; i++) {
            sb.append(paddingCharacter);
        }/*w w  w  .  ja va  2  s  . c  o  m*/
        sb.append(s);
        return sb.toString();
    }
}

Related

  1. leftPad(String in, char padding, int length)
  2. leftPad(String input, char padding, int length)
  3. leftPad(String input, int length, char pad)
  4. leftPad(String inStr, int length, char paddingChar)
  5. leftPad(String original, int length, char padChar)
  6. leftPad(String s, int l)
  7. leftPad(String s, int len, char c)
  8. leftPad(String s, int length)
  9. leftPad(String s, int length)