I have a string and I want to pad this string by any given character to a given length. off course I can write a loop statement and get the job done but thats not what I am looking for.
One approach I used was
myString = String.format("%1$"+ n + "s", myString).replace(' ', newChar);
this works fine except when myString already has a space in it. Is there a better solution using String.format()