📅  最后修改于: 2022-03-11 14:52:46.443000             🧑  作者: Mango
Have a look at org.apache.commons.lang.StringUtils#rightPad(String str, int size, char padChar).
But the algorithm is very simple (pad right up to size chars):
public String pad(String str, int size, char padChar)
{
StringBuilder padded = new StringBuilder(str);
while (padded.length() < size)
{
padded.append(padChar);
}
return padded.toString();
}