I am trying to benchmark sorting methods. My writeCSV(String) method writes over the first line every time I call it. Here is my code:
public static void main(String[] args) throws Exception{
writeCSV("data size (100 times),bubble,insertion,merge,quick");
sortRandomSet(20);
}
public static void sortRandomSet(int setSize) throws Exception
{
.
.
.
writeCSV(setSize+","+bTime+","+mTime+","+iTime+","+qTime);
}
/*******************************************************************************
* writeCSV(course[]) method
* Last edited by Steve Pesce 3/19/2014 for CSci 112
* Writes String to CSV
*
*/
public static void writeCSV(String line) throws Exception {
//create new File object
java.io.File courseCSV = new java.io.File("benchmark.csv");
//create PrintWriter object on new File object
java.io.PrintWriter outfile = new java.io.PrintWriter(courseCSV);
outfile.write(line + "\n");
outfile.close();
}//end writeCSV(String)
I want writeCSV to start on a new line every time it is called, is this possible to do?