code: public static String rpad(String base, Integer len, String pad)
    {
      if (len < 0) {
        return null;
      } else if (len == 0) {
        return "";
      }
  
      char[] data = new char[len];
  
      int pos = 0;
  
      // Copy the base
      for ( ; pos < base.length() && pos < len; pos++) {
        data[pos] = base.charAt(pos);
      }
  
      // Copy the padding
      for ( ; pos < len; pos += pad.length()) {
        for (int i = 0; i < pad.length() && i < len - pos; i++) {
          data[pos + i] = pad.charAt(i);
        }
      }
  
      return new String(data);
    }
docs: Returns the string right-padded with the string pad to a length of len characters.
  If str is longer than len, the return value is shortened to len characters.
  
  @param base The base string to be padded
  @param len The length of padded string
  @param pad The pad string
  @return the string right-padded with pad to a length of len