DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Java字符串的格式化输出


左对齐 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



Published

Sep 7, 2012

Last Updated

Sep 7, 2012

Category

Tech

Tags

  • 对齐 1
  • format 6
  • Java 106
  • string 3

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor