Here you can find the source of rightPad(String str, String pad, int len)
public static String rightPad(String str, String pad, int len)
//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; } }