code: public static String fillWithSpaces(String input, int lenght, final Alignment textAlignment) {
          String spaces = "";
          for (int i = lenght - input.length(); i > 0; i--) {
              spaces += " ";
          }
          switch (textAlignment) {
              case RIGHT:
                  return spaces + input;
              case CENTER:
                  final int half_spaces_size = (lenght - input.length()) / 2;
                  return spaces.substring(0, half_spaces_size - 1) + input + spaces.substring(half_spaces_size);
              case LEFT:
              default:
                  return input + spaces;
          }
      }
docs: Method fills the given input string with width-spaces until the given string length is reached.
  <p>
  Note: The origin input string will aligned to the left.
  
  @param input         the original input string
  @param lenght        the requested input string length.
  @param textAlignment the alignment of the origin input string.
  
  @return the extended input string