Java String Pad Right rightPad(String str, int num, String padStr)

Here you can find the source of rightPad(String str, int num, String padStr)

Description

right Pad

License

Apache License

Declaration

public static String rightPad(String str, int num, String padStr) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String rightPad(String str, int num, String padStr) {
        if (num <= 0) {
            return str;
        }/*from   www  . j  ava2 s .c  om*/
        StringBuilder sb = new StringBuilder(str.length() + num);
        sb.append(str);
        while (num-- > 0) {
            sb.append(padStr);
        }
        return sb.toString();
    }
}

Related

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