java字符串固定长度,左补空格,或右补空格
String a = String.format("%5s", "abc");
log.info("a=[{}]", a);
打印:a=[ abc]
String b = String.format("%-5s", "abc");
log.info("b=[{}]", b);
打印:b=[abc ]
![](https://images.cnblogs.com/cnblogs_com/zhuwenjoyce/945554/o_201113020411my-zhifubao-shouqianma.jpeg)
String a = String.format("%5s", "abc");
log.info("a=[{}]", a);
打印:a=[ abc]
String b = String.format("%-5s", "abc");
log.info("b=[{}]", b);
打印:b=[abc ]