有几种方法:leftPad,[rightPad](https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/StringUtils.html#rightPad(java.lang.String,%20int)
,center和repeat。
但请注意-如其他人所说的,并证明了这个答案 -
String.format()和
FormatterJDK中的类是更好的选择。在公共代码上使用它们。



