I would like to create a string that HAVE trailing spaces to complete a stringbuffer width.
e.g:
Stringbuffer str = new Stringbuffer(10); //Create a string with 10 spaces.
str.append("Hello");
The output is
“Hello” without any trailing spaces.
But what I want is “Hello” with 5 trailing spaces.
In the above example, since “Hello” has 5 characters, there should be 5 more trailing spaces after it.
Please advice, thx
Just append a space until the length is less than 10: