How do I export the ArrayList to a CSV file
<p>I have this code, it gets the average grade, but I need to export the arraylist Hell to a CSV file. How do I do this?</p>

<pre><code>import java.util.*;
import java.io.*;
import java.io.PrintWriter;
import java.text.*;
public class hello3 {
    public static void main(String[] args)
  {
    Scanner in = new Scanner(System.in);

    System.out.printf("Please enter the name of the input file: ");
    String input_name = in.next();
    System.out.printf("Please enter the name of the output CSV file: ");
    String csv_name = in.next();
    System.out.printf("Please enter the name of the output pretty-print file: ");
    String pretty_name = in.next();

    processGrades(input_name, csv_name, pretty_name);
    System.out.printf("\nExiting...\n");
  }
      public static void processGrades (String input_name, String csv_name, String pretty_name)
  {
      PrintWriter csv = null;
      PrintWriter pretty = null;
      String[][] data = readSpreadsheet(input_name);

      boolean resultb = sanityCheck(data);
      int length = data.length;
      ArrayList&lt;String&gt; test_avg = new ArrayList&lt;String&gt;();
      ArrayList&lt;String&gt; HW_avg = new ArrayList&lt;String&gt;();
      ArrayList&lt;String&gt; NAME = new ArrayList&lt;String&gt;();
      ArrayList&lt;String&gt; ColN = new ArrayList&lt;String&gt;();
      ArrayList&lt;String&gt; Hell = new ArrayList&lt;String&gt;();
      for(int row = 1; row&lt;length; row++)
      {
          String name = data[row][0];
          String name2 = data[row][1];
          String Name = name+" "+name2;
          int test1 = Integer.parseInt(data[row][2]);
          int test2 = Integer.parseInt(data[row][3]);
          int test3 = Integer.parseInt(data[row][4]);
          int Test = (test1+test2+test3)/3;
          String Testav = Integer.toString(Test);
          int hw1 = Integer.parseInt(data[row][5]);
          int hw2 = Integer.parseInt(data[row][6]);
          int hw3 = Integer.parseInt(data[row][7]);
          int hw4 = Integer.parseInt(data[row][8]);
          int hw5 = Integer.parseInt(data[row][9]);
          int hw6 = Integer.parseInt(data[row][10]);
          int hw7 = Integer.parseInt(data[row][11]);
          int HW = (hw1+hw2+hw3+hw4+hw5+hw6+hw7)/7;
          int[] trying = {Test, HW};
          int low = find_min(trying);
          String grade = null;
          if(low&gt;=90)
          {
              grade ="A";
          }
          if(low &lt; 90&amp;&amp; low&gt;= 80)
          {
           grade = "B";   
          }
          if(low &lt;80&amp;&amp;low&gt;=70)
          {
              grade ="C";
          }
          if(low&lt;70&amp;&amp;low&gt;=60)
          {
              grade="D";
          }
          if(low&lt;60)
          {
              grade = "F";
          }
          String Lows = Integer.toString(low);
          String HWav = Integer.toString(HW);
          test_avg.add(Testav);
          HW_avg.add(HWav);
          NAME.add(Name);
          Hell.add(Name);
          Hell.add(Testav);
          Hell.add(HWav);
          Hell.add(Lows);
          Hell.add(grade);

          System.out.println(Hell);
          System.out.printf("\n");


      }
  }


      public static int find_min(int[] values)
      {
          int result = values[0];
          for(int i = 0; i&lt;values.length; i++)
          {
              if(values[i]&lt;result)
              {
                  result = values[i];
              }
          }
          return result;
      }
  public static boolean sanityCheck(String[][] data)
  {
      if (data == null)
              {
                  System.out.printf("Sanity check: nul data\n");
                  return false;
              }
      if(data.length&lt;3)
      {
          System.out.printf("Sanity check: %d rows\n",data.length);
          return false;
      }
      int cols= data[0].length;
      for(int row = 0; row&lt;data.length; row++)
      {
          int current_cols = data[row].length;
          if(current_cols!=cols)
          {
              System.out.printf("Sanity Check: %d columns at rows%d\n", current_cols, row);
              return false;
          }
      }

      return true;
  }
  public static String[][] readSpreadsheet(String filename)
  {
    ArrayList&lt;String&gt; lines = readFile(filename);
    if (lines == null)
    {
      return null;
    }

    int rows = lines.size();
    String[][] result = new String[rows][];

    for (int i = 0; i &lt; rows; i++)
    {
      String line = lines.get(i);
      String[] values = line.split(",");
      result[i] = values;
    }

    return result;
  }

  public static ArrayList&lt;String&gt; readFile(String filename)
  {
    File temp = new File(filename);
    Scanner input_file;

    try
    {
      input_file = new Scanner(temp);
    } catch (Exception e)
    {
      System.out.printf("Failed to open file %s\n",
              filename);
      return null;
    }

    ArrayList&lt;String&gt; result = new ArrayList&lt;String&gt;();
    while (input_file.hasNextLine())
    {
      String line = input_file.nextLine();
      result.add(line);
    }

    input_file.close();
    return result;
  }
}
</code></pre>

<p>Any help would be appreciated. thank you.</p>