zoukankan      html  css  js  c++  java
  • 将指定内容写入目标文件(日志)

    public static void logResult(String str) {      //str 要写入的内容
      FileWriter writer = null;
      try {
        // String s = AlipayConfig.log_path + "//log//"+"alipay_log_" + System.currentTimeMillis()+".txt";
        String s = "F://myeclipse85//log//"+System.currentTimeMillis()+".txt";
        File file = new File(s); 
        if(!file.exists()){
          file.createNewFile();
        }
        writer = new FileWriter(file);
        writer.write(str);
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        if (writer != null) {
          try {
            writer.close();
          } catch (IOException e) {
            e.printStackTrace();
          }
        }
      }

    }

  • 相关阅读:
    HDU 4285
    Codeforces 242C
    Codeforces 811C
    Codeforces 883H
    Codeforces 371D
    Codeforces 926E
    牛客算法周周练17 解题报告
    牛客算法周周练17D
    牛客算法周周练17C
    牛客算法周周练17A
  • 原文地址:https://www.cnblogs.com/liuqu/p/8657691.html
Copyright © 2011-2022 走看看