Displaying Output To A Text File In Java?
is there a way to display output to a text file in java. For example i have two variables (both strings) and i want to print them to a text file. any suggestions. below is what i have tried using but i'm getting errors.
java.io.File outfile;
java.io.PrintWriter pen;
outfile = new java.io.File("ask.txt");
pen = new java.io.PrintWriter(outfile);
outfile.println(time + date);
java.io.File outfile;
java.io.PrintWriter pen;
outfile = new java.io.File("ask.txt");
pen = new java.io.PrintWriter(outfile);
outfile.println(time + date);
try pen.println instead of outfile.println
try pen.println instead of outfile.println