使用命令行参数时无法写入文件

时间:2016-12-01 01:43:13

标签: java command-line arguments bufferedwriter

当我没有放置命令行参数时,我可以写入该文件但是每当我放置命令行参数时它都不会写入。即使我甚至没有使用命令行参数。

get_view_post:
   path:     /blog/get/one/post/{id}/
   defaults: { _controller: "MyAppBlogBundle:Blog:getpost" }
Update_comment:
   path:     /blog/get/post/Comment/Update/View/{idc}
   defaults: { _controller: "MyAppBlogBundle:Blog:UpdateComment" }

1 个答案:

答案 0 :(得分:1)

您需要flush RAMHDD|SSD的数据,所以:

try (FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw)) {
      // Write the data to the memory
      bw.write(content);
      // You need to flush the data
      bw.flush();
      // Close the BufferedWriter
      bw.close();
} catch (Exception ex) {
      Logger.getLogger(getClass().getName()).log(Level.SEVERE, "Failed to write the data on the file", ex);
}