Java String Pad Right rightPad(String str, int len, char c)

Here you can find the source of rightPad(String str, int len, char c)

Description

right Pad

License

Open Source License

Declaration

public static String rightPad(String str, int len, char c) 

Method Source Code

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

public class Main {
    public static String rightPad(String str, int len, char c) {
        if (str.length() >= len)
            return str;
        StringBuilder ret = new StringBuilder(str);
        while (ret.length() < len)
            ret.append(c);/*from  w  w  w.j  av a  2s .  com*/
        return ret.toString();
    }

    public static String rightPad(String str, int len) {
        return rightPad(str, len, ' ');
    }
}

Related

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