gpt4 book ai didi

java - 如果文件不存在,PrinterWriter 是否会创建该文件?

转载 作者:行者123 更新时间:2023-12-01 21:15:25 25 4
gpt4 key购买 nike

我正在使用 PrintWriter 对象 文件,如下所示:

PrintWriter pwriter = new PrintWriter("abc.txt");

如果文件名 abc.txt 不存在,请告诉我是否会创建该文件。

我已经尝试过了,但它没有创建文件。但我想确认是否预期不创建该文件。

最佳答案

来自javadoc :

fileName - The name of the file to use as the destination of this writer. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.

关于java - 如果文件不存在,PrinterWriter 是否会创建该文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40276888/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com