Here you can find the source of rightPad(String srcString, char c, int length)
public static String rightPad(String srcString, char c, int length)
//package com.java2s; //License from project: Apache License public class Main { public static String rightPad(String srcString, char c, int length) { if (srcString == null) { srcString = ""; }/*from ww w. j ava 2 s .co m*/ int tLen = srcString.length(); if (tLen >= length) return srcString; int iMax = length - tLen; StringBuffer sb = new StringBuffer(); sb.append(srcString); for (int i = 0; i < iMax; ++i) { sb.append(c); } return sb.toString(); } }