注意writer的参数有多个,特别是有一个boolean的参数决定刷新或在附加文本
log = new PrintWriter( new FileOutputStream(fl, true ), true ); SimpleDateFormat df = new SimpleDateFormat( " yyyy.MM.dd 'at' hh:mm:ss\n " ); Date now = new Date(); String dateformat = df.format(now) BufferedWriter bf = new BufferedWriter( new FileWriter(fl, true )); bf.append(dateformat); bf.close(); log.println( " start connection databse: " ); log.println( " driver name: " .concat(driveName);