this is a very basic question, but can't seem to get the right answer on myProgrammingLab.
Declare a local variable output that is suitable for referring to an object that provides methods for writing to a text file.
this is a very basic question, but can't seem to get the right answer on myProgrammingLab.
Declare a local variable output that is suitable for referring to an object that provides methods for writing to a text file.
You can declare a PrintWriter
, which provides methods for writing to text files:
PrintWriter output = new PrintWriter("textfile.txt");
To use it:
output.println("hello");
output.close();
You'll need a try/catch block for an IOException
.