Java String Pad Right rightPaddedBaseString(String bases, int length)

Here you can find the source of rightPaddedBaseString(String bases, int length)

Description

right Padded Base String

License

Open Source License

Declaration

public static String rightPaddedBaseString(String bases, int length) 

Method Source Code

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

public class Main {
    public static String rightPaddedBaseString(String bases, int length) {
        return rightPaddedString(bases, length, '-');
    }//from www.j a v  a  2s . c om

    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;
        }
        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 length)
  2. rightPad(String value, int makeLength, char paddingCharacter)
  3. rightPad(String value, int tamanho, String pad)
  4. rightPad(StringBuilder pStringBuilder, int pLength, char pChar)
  5. rightPadded(String src, int len)
  6. rightPaddedString(String string, int length, char paddingChar)
  7. rightPadding(int id, int value)
  8. rightPaddWithSpace(String pString_, int stellen)
  9. rightPadInt(int number, int width)