Writing data to a text file in Java
Writing Data to a Text File The simplest way to write text to a file requires us to use PrintWriter class from the standard package java.io . The class PrintWriter has the familiar print() and println() methods we have been using for writing to the console. The following program writes the name of four oceans…