【发布时间】:2016-11-22 20:06:14
【问题描述】:
我正在使用这种方法从文本文件中打印一些数据,并尝试将其输出为表格格式。
第一个参数只是请求一个必须在中间列的单词,colSize 应该设置列宽。
public String printTable(String midWord, int colSize) {
String col1 = "";
String col2 = midWord;
String col3 = "";
System.out.printf( "%-15s %15s %n", col1, midWord, col3);
//System.out.format ( "%-15s %15s %n", col1, midWord, col3);
return null;
}
我尝试过同时使用printf 和System.out.format,但它们似乎都在做同样的事情,所以我不确定。
谁能解释我在这种方法中缺少什么。
【问题讨论】:
-
你能显示文件的内容和解析文件的代码吗?
-
有什么问题?
colSize在哪里使用? -
@LaneSurface 我不知道如何使用它...☹️
标签: java format output text-files