Java String Pad Right rightPad(String str, int length, char padding)

Here you can find the source of rightPad(String str, int length, char padding)

Description

right Pad

License

Open Source License

Declaration

public static String rightPad(String str, int length, char padding) 

Method Source Code

//package com.java2s;

public class Main {

    public static String rightPad(String str, int length, char padding) {
        if (str == null) {
            str = "";
        }/* w  w w  .  j a  v a2s.com*/
        if (length == 0 || str.length() > length) {
            return str;
        }
        for (int i = str.length(); i < length; i++) {
            str += padding;
        }
        return str;
    }
}

Related

  1. rightPad(String s, int width)
  2. rightPad(String s, int z)
  3. rightPad(String srcStr, char padChar, int destLen)
  4. rightPad(String srcString, char c, int length)
  5. rightPad(String str, int len, char c)
  6. rightPad(String str, int max, char pad)
  7. rightPad(String str, int num, String padStr)
  8. rightPad(String str, int size)
  9. rightPad(String str, int size)