Throws: FileNotFoundException - If the given file object does not
denote an existing, writable regular file and a new regular file of
that name cannot be created, or if some other error occurs while
opening or creating the file
# 2 楼答案
请查看Javadoc API,其中说明:
Throws: FileNotFoundException - If the given file object does not
denote an existing, writable regular file and a new regular file of
that name cannot be created, or if some other error occurs while
opening or creating the file
# 1 楼答案
FileNotFoundException
不一定表示文件不存在。例如,如果传入的名称表示目录而不是文件,jvm将无法写入相应的句柄,并将通过异常报告相同的句柄根据java文档
# 2 楼答案
请查看Javadoc API,其中说明:
[1]https://docs.oracle.com/javase/7/docs/api/java/io/PrintWriter.html#PrintWriter(java.io.File)