我正在使用此方法从文本文件中打印一些数据,并尝试将其输出为表格格式。 第一个参数只是请求一个必须位于中间列的字,而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
,但他们似乎都在做同样的事情,试图所以我不知道他们。
任何人都可以解释我缺少这种方法。
你可以显示文件的内容和解析文件的代码吗? – vlatkozelka
什么问题? colSize在哪里? – 2016-11-22 20:21:49
@LaneSurface我不知道如何使用它...well️ – RS786