CString.Format 左补齐或者右补齐空格

来源:互联网 发布:淘宝页头尺寸是多少 编辑:程序博客网 时间:2024/06/05 11:03
public class Test {
public static void main(String[] args) {
String str="123";
System.out.println("右补空:["+String.format("%1$-20s", str)+"]");  // 右补齐
System.out.println("左补空:["+String.format("%1$20s", str)+"]");  //左补齐
}
}