我正在使用 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/