Here you can find the source of rightPadString(String str, char pad, int length)
public static String rightPadString(String str, char pad, int length)
//package com.java2s; //License from project: Apache License public class Main { public static String rightPadString(String str, char pad, int length) { if (str.length() >= length) return str; StringBuffer sb = new StringBuffer(str); while (sb.length() < length) sb.append(pad);/*from w w w . ja v a 2 s . c o m*/ return sb.toString(); } }