how to write to a file in java using printwriter code example Example: java printwriter create file File Fileright = new File("C:\\NewFile.txt");