2
使用writer.format并传递预定义的格式字符串(%5s%10s ...),将字符串数组解析为单独参数的最佳方法是什么?如何传递多个数组值作为格式参数?
所以,如果我有:
Printwriter writer = new Printwriter ("table.txt");
String[] columns = {"Name", "Month", "Day"};
String form_string = "%20s%10s%5s";
如何传递数组元素的名称,月,日为ARG1,ARG2,ARG3在:
writer.format(form_string, arg1, arg2, arg3);
我们能不能在这个问题中得到一些例子 – Aaron
增加样例代码 – PeterSon
留在'writer.format(form_string,columns [0],columns [1],columns [2]);'。最明显的。附:为什么不用“%-20s”左对齐的填充? –