try {
  String path = "D:\log\count.txt";  // define FileWriter instance (parameter true: Its mean append the message to log-file.)
  FileWriter fileWriter = new FileWriter(path,true);  // define BufferedWriter instance
  BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);  bufferedWriter.write(message); // write message to log-file.
  bufferedWriter.newLine(); // write new line to log-file.
  bufferedWriter.close();   // close the BufferedWriter instance.
  fileWriter.close();       // close the FileWriter stream  } catch(IOException ioe) {
  } catch(Exception ex) {
  }
java.io.FileWriter fileWriter = new java.io.FileWriter(path,true);
//传入参数true,表示为向文件中追加数据;
//        false,表示为替换原文件中的内容.