Java String Pad Left leftPad(final String value, final int length, final char paddingChar)

Here you can find the source of leftPad(final String value, final int length, final char paddingChar)

Description

left Pad

License

Open Source License

Declaration

public static String leftPad(final String value, final int length, final char paddingChar) 

Method Source Code

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

public class Main {
    public static String leftPad(final String value, final int length, final char paddingChar) {
        final StringBuilder sb = new StringBuilder(value);
        while (sb.length() < length) {
            sb.insert(0, paddingChar);//from  w  w w  .  j  a v  a2s . c  om
        }
        return sb.toString();
    }
}

Related

  1. leftAlignedPaddedString(String input, int length)
  2. leftPad(byte[] data, int size, byte pad)
  3. leftPad(final String input, final int size)
  4. leftPad(final String numStr, final int numDigits)
  5. leftPad(final String str, final int size, String padStr)
  6. leftPad(long value, char padChar, int maxDigits, StringBuilder buf)
  7. leftPad(Object obj, char pad, int len)
  8. leftPad(String _str, int _size, char _padChar)
  9. leftPad(String aStr, int aLen)