Java String Pad Right rightPaddedString(String string, int length, char paddingChar)

Here you can find the source of rightPaddedString(String string, int length, char paddingChar)

Description

right Padded String

License

Open Source License

Declaration

public static String rightPaddedString(String string, int length, char paddingChar) 

Method Source Code

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

public class Main {
    public static String rightPaddedString(String string, int length, char paddingChar) {
        if (string.length() > length) {
            System.err.println("WARNING: String to pad is longer than expected length. Return original string.");
            return string;
        }/*from  w ww . ja va2 s  . co m*/
        if (string.length() == length)
            return string;
        return string.concat(String.format("%0" + (length - string.length()) + "d", 0).replace('0', paddingChar));
    }
}

Related

  1. rightPad(String value, int makeLength, char paddingCharacter)
  2. rightPad(String value, int tamanho, String pad)
  3. rightPad(StringBuilder pStringBuilder, int pLength, char pChar)
  4. rightPadded(String src, int len)
  5. rightPaddedBaseString(String bases, int length)
  6. rightPadding(int id, int value)
  7. rightPaddWithSpace(String pString_, int stellen)
  8. rightPadInt(int number, int width)
  9. rightPadOrTruncate(String str, int resultSz)