Here you can find the source of rightPad(String _str, int _size, char _padChar)
public static String rightPad(String _str, int _size, char _padChar)
//package com.java2s; public class Main { public static String rightPad(String _str, int _size, char _padChar) { if (_str == null) { return null; }//from w ww .j a v a 2 s . c om int pads = _size - _str.length(); if (pads <= 0) { return _str; // returns original String when possible } return _str.concat(padding(pads, _padChar)); } private static String padding(int _repeat, char _padChar) { String value = ""; String padStr = String.valueOf(_padChar); if (_repeat > 0) { for (int i = 0; i < _repeat; i++) { value = value.concat(padStr); } } return value; } }