I am trying to print this to a file:
try { PrintWriter outfile = new PrintWriter(new FileWriter("CD.txt", true)); outfile.println(title+","+singer+","+price+","+Category+","+discount + ","); for(int t=0;t<NumOfTracks;t++){ Tracks[t]=(Newtrack); duration[t]=(Newtime); outfile.println(Tracks[t] + "," + duration[t]+ ","); t++; } outfile.close(); }
Whenever i print it to the file, i get
title,singer,price,category,discount,track1,time1
title,singer,price,category,discount,track2,time2
I want it to be like this
title,singer,price,category,discount,track1,time1, track2,time2.
Why is it printing the same thing again and writting the track2 and time2 to it?
Thank you