如果文件不存在,PrinterWriter 会创建一个文件吗?
Does PrinterWriter creates a file if it doesn't exists?
我正在使用 PrintWriter object
文件如下:
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.
我正在使用 PrintWriter object
文件如下:
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.