Java 找不到适合PrintWriter的构造函数(文件,布尔值)

Java 找不到适合PrintWriter的构造函数(文件,布尔值),java,printwriter,Java,Printwriter,当我使用PrintWriter(file,true)时会显示错误 找不到适合PrintWriter的构造函数(文件,布尔值) 如何解决它,谢谢PrintWriter类没有接受文件、布尔值的构造函数 最好删除布尔值,然后只传递文件 请参阅从中获取的完整列表 PrintWriter类没有任何将2个参数文件和布尔值一起接受的构造函数 因此,您必须删除布尔参数,并按如下方式编写代码- PrintWriter(File file) Creates a new PrintWriter, without a

当我使用
PrintWriter(file,true)
时会显示错误

找不到适合PrintWriter的构造函数(文件,布尔值)


如何解决它,谢谢

PrintWriter
类没有接受
文件、布尔值的构造函数

最好删除
布尔值
,然后只传递
文件

请参阅从中获取的完整列表


PrintWriter类没有任何将2个参数文件和布尔值一起接受的构造函数

因此,您必须删除布尔参数,并按如下方式编写代码-

PrintWriter(File file) 
Creates a new PrintWriter, without automatic line flushing, with the specified file.

PrintWriter(File file, String csn) 
Creates a new PrintWriter, without automatic line flushing, with the specified file and charset.

PrintWriter(OutputStream out) 
Creates a new PrintWriter, without automatic line flushing, from an existing OutputStream.

PrintWriter(OutputStream out, boolean autoFlush) 
Creates a new PrintWriter from an existing OutputStream.

PrintWriter(String fileName) 
Creates a new PrintWriter, without automatic line flushing, with the specified file name.

PrintWriter(String fileName, String csn) 
Creates a new PrintWriter, without automatic line flushing, with the specified file name and charset.

PrintWriter(Writer out) 
Creates a new PrintWriter, without automatic line flushing.

PrintWriter(Writer out, boolean autoFlush) 
Creates a new PrintWriter. 

你考虑过咨询Javadoc吗?你不能只是编造一些东西然后想知道它们为什么不存在。@Tom可能是如何复制的?@EJP OP显然想实例化一个
PrintWriter
,它附加到一个现有的源,那里的答案告诉他如何做。@Tom这是一个相当大的假设,因为
PrintWriter
上的构造函数采用布尔值启用自动刷新。@MarkrotVeel是的,这是真的,但我不认为OP的目标是这样。不过,我可能错了。所以,经过再三考虑,这并不是那么“清楚”。
PrintWriter(File file) 
Creates a new PrintWriter, without automatic line flushing, with the specified file.

PrintWriter(File file, String csn) 
Creates a new PrintWriter, without automatic line flushing, with the specified file and charset.

PrintWriter(OutputStream out) 
Creates a new PrintWriter, without automatic line flushing, from an existing OutputStream.

PrintWriter(OutputStream out, boolean autoFlush) 
Creates a new PrintWriter from an existing OutputStream.

PrintWriter(String fileName) 
Creates a new PrintWriter, without automatic line flushing, with the specified file name.

PrintWriter(String fileName, String csn) 
Creates a new PrintWriter, without automatic line flushing, with the specified file name and charset.

PrintWriter(Writer out) 
Creates a new PrintWriter, without automatic line flushing.

PrintWriter(Writer out, boolean autoFlush) 
Creates a new PrintWriter. 
File file = new File("output.txt");

PrintWriter output = new PrintWriter(file);