public static String rightPad(String str, final int size, final char padChar) {
    int length = 0;
    if (str != null) {
      length = str.length();
    }

    final int pads = size - length;
    if (pads <= 0) {
      return str; // returns original String when possible
    }
    char[] buf = new char[size];

    for (int i = 0; i < length; i++) {
      buf[i] = str.charAt(i);
    }
    for (int i = str.length(); i < size; i++) {
      buf[i] = padChar;
    }
    return String.valueOf(buf);
  }
@Test(priority = 0)
  public void testRightPad() {
    assertEquals("str ", TextTable.rightPad("str", 4, ' '));
  }