File file = new File("output.txt");
PrintWriter output = new PrintWriter(file,true);
When I use PrintWriter(file,true)
it's show me error
"no suitable constructor found for PrintWriter(File, boolean)"
how to solve it ,Thanks
File file = new File("output.txt");
PrintWriter output = new PrintWriter(file,true);
When I use PrintWriter(file,true)
it's show me error
"no suitable constructor found for PrintWriter(File, boolean)"
how to solve it ,Thanks
PrintWriter
class doesn't have a constructor that accepts File, Boolean
Your best bet is to remove the Boolean
, and just pass the File
.
See full list taken from Oracle
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.
PrintWriter class does not have any constructor that take 2 parameter File and boolean together.
So You have to remove boolean parameter.and write code as-
File file = new File("output.txt");
PrintWriter output = new PrintWriter(file);