模拟试题

3773考试网计算机等级考试模拟试题正文

2011计算机二级JAVA编程:写入日志

来源:fjzsksw.com 2010-11-11 9:19:13

 

 

  写入日志

  /**

  * 写入日志

  * filePath 日志文件的路径

  * code 要写入日志文件的内容

  */

  public static boolean print(String filePath,String code) {

  try {

  File tofile=new File(filePath);

  FileWriter fw=new FileWriter(tofile,true);

  BufferedWriter bw=new BufferedWriter(fw);

  PrintWriter pw=new PrintWriter(bw);

  System.out.println(getDate()+":"+code);

  pw.println(getDate()+":"+code);

  pw.close();

  bw.close();

  fw.close();

  return true;

  } catch (IOException e) {

  return false;

  }

  }

 

 

触屏版 电脑版
3773考试网 琼ICP备12003406号-1