我尝试用padding打印字符串(像表一样):
StringBuilder sb = new StringBuilder();
sb.append(String.format("%1$15s", "bulk name"));
sb.append(String.format(" | "));
sb.append(String.format("%1$15s", "baseline"));
sb.append(String.format(" | "));
sb.append(String.format("%1$15s", "current"));
sb.append(String.format(" | "));
sb.append("\n");
for (int i = 0; i < baseLine.tillOneSecondBulks.size(); i++) {
sb.append(String.format("%1$15s", baseLine.tillOneSecondBulks.get(i).bulkName));
sb.append(String.format(" | "));
sb.append(String.format("%1$15s", baseLine.tillOneSecondBulks.get(i)
.count));
sb.append(String.format(" | "));
sb.append(String.format("%1$15s", current.tillOneSecondBulks.get(i)
.count));
sb.append(String.format(" | "));
sb.append("\n");
sb.append("\n");
}
sb.append("\n");
sb.append("\n");
但仍然没有订购:
bulk name | baseline | current |
[0,0.2) seconds | 0 | 0 |
[0.2,0.4) seconds | 0 | 0 |
[0.4,0.6) seconds | 0 | 0 |
[0.6,0.8) seconds | 0 | 1 |
[0.8,1) seconds | 1 | 0 |
答案 0 :(得分:1)
尝试增加标题的长度以及第一个字段的每一行。如果你看到的原因,例如[0.2,0.4) seconds
超过15个字符。
尝试将其增加到20个字符,这样可以解决问题。