String str1 = String.format("%5s", "dgg");
String str2 = String.format("%-5s", "dgg");
System.out.println("++"+str1+"++");
System.out.println("++"+str2+"++");
String str3=String.format("%05d", Integer.parseInt("55"));
System.out.println("++"+str3+"++");
原文地址:http://5618698.blog.51cto.com/5608698/1629558