What is wrong?
I am trying to print this to a file:
Whenever i print it to the file, i get
PrintWriter outfile = new PrintWriter(new FileWriter("CD.txt", true));
outfile.println(title+","+singer+","+price+","+Category+","+discount + ",");
outfile.println(Tracks[t] + "," + duration[t]+ ",");
I want it to be like this
Why is it printing the same thing again and writting the track2 and time2 to it?
You don't really give us enough information to answer your question. What is (Newtrack) and (Newtime)? What is NumOfTracks?
If you want help with code, make sure it's in SSCCE form. That doesn't mean post all of our code- it means narrow your code down to as few lines as possible while still being runnable and showing the problem.
The code you posted prints two lines (because there are two println() statements). These lines don't resemble either the output you want or the output you say you get.
Also data is being appended to outfile, so the output you see may have come from different runs of the program.
It might help if you posted a short compilable example that others can run to see the problem for themselves. It does not have to be long: just enough to illustrate the problem. Copy and post actual output from the program along what you would prefer the output to be,