如何使用PrintWriter格式化输出文件。
预期产出
09/12/2014 11:58:55 | 9999999996 | Member - validateBp | VALIDATING IN REGISTRATION
09/12/2014 11:58:55 | null | LoginServlet - processRequest | ACCESSING PAGE
当前输出
09/12/2014 11:58:55 9999999996 Member - validateBp VALIDATING IN REGISTRATION
09/12/2014 12:11:00 null LoginServlet - processRequest ACCESSING PAGE
谢谢!
答案 0 :(得分:0)
试
使用String.format
让我们假设所有String
除id
int
out.println(String.format("%10s|%10d|%10s|%10s|%10s", date, id, classname.toUpperCase() ,functioname.toUpperCase() + details));
答案 1 :(得分:0)
String formattedDate = new SimpleDateFormat(" dd / MM / yyyy,HH:mm:ss")。format(date));
String Sid = Integer.toString(id);
out.println(String.format("%s |%s |%s |%s,formattedDate,Sid,classname.toUpperCase(),functioname.toUpperCase()+ details));
或
out.println(String.format("%10s |%10d |%10s |%10s",date,id,classname.toUpperCase(),functioname.toUpperCase()+ details));
获得4个参数。