//Instantiate a stream, and a PrintWriter FileOutputStream streamVariableName = newFileOutputStream(fileNameOrPath); PrintWriter printerVariableName = new PrintWriter(streamVariableName) //Write a string to the file printerVariableName.print(string); //Write a string and a newline to the file printerVariableName.println(string); //Close the file streamVariableName.close();