Studyon Minte9.com
Java SE




Padding




package testexample; import javax.swing.*; public class Test extends JFrame { public static void main(String[] args) { String a = String.format("%6s", "abc").replace(" ", "*"); System.out.println(a); // Output: ***abc String b = String.format("%3s", "?").replace(" ", "?, "); System.out.println(b); // Output: ?, ?, ? } }
 


http://stackoverflow.com/questions/388461/how-can-i-pad-a-string-in-java