左对齐 String LS_HEADER = String.format("%-10s%-10s%-10s%-10s%-10s%-10s%n",
"ID", "Protocol", "IP", "Port", "Username", "Password");
效果:
ID Protocol IP Port Username Password
10025022 ssh 10.0.2.50 22 godu godu
10024723 telnet 10.0.2.47 23 godu goduty
右对齐
String LS_HEADER = String.format("%10s%10s%10s%10s%10s%10s%n",
"ID", "Protocol", "IP", "Port", "Username", "Password");
效果:
ID Protocol IP Port Username Password 10025022 ssh 10.0.2.50 22 godu godu 10024723 telnet 10.0.2.47 23 godu goduty