Demonstrate how to write text to a text file in JAVA using Printer class.