// Java PrintWriter class is the implementation of Writer class.
// It is used to print the formatted representation of objects
// to the text-output stream.
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
class PrintWriterDemo {
public static void main(String[] args)
throws FileNotFoundException, IOException {
PrintWriter writer = new PrintWriter(System.out);
//Writing on console
writer.write("Java Invent");
writer.flush();
writer.close();
//writing in a file using printStream
PrintWriter writer1 = new PrintWriter("printwriter.txt");
writer1.write("welcome to Java Invent");
System.out.println("Success....");
writer1.flush();
writer1.close();
}
}