Java String Pad Right rightPad(String str, String pad, int len)

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

Description

right Pad

License

Open Source License

Declaration

public static String rightPad(String str, String pad, int len) 

Method Source Code

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

public class Main {

    public static String rightPad(String str, String pad, int len) {
        String newStr = (str == null ? "" : str);
        while (newStr.length() < len) {
            newStr = newStr + pad;//from w  ww  .  ja v a2s .  com
        }
        if (newStr.length() > len) {
            newStr = newStr.substring(0, len);
        }
        return newStr;
    }
}

Related

  1. rightPad(String str, int size, char padChar)
  2. rightPad(String str, int size, char padChar)
  3. rightPad(String str, int size, String padStr)
  4. rightPad(String str, int width)
  5. rightPad(String str, int width, char padding)
  6. rightPad(String string, int length)
  7. rightPad(String strInput, int intLength)
  8. rightPad(String targetStr, char appendChar, int length)
  9. rightPad(String toPad, int totalLength)