code: public static void writeCSVColumns(XYSeries series, String path2Dir) {
  
      File newFile = new File(path2Dir + series.getName() + ".csv");
      Writer out = null;
      try {
  
        out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(newFile), "UTF8"));
        double[] xData = series.getXData();
        double[] yData = series.getYData();
        double[] errorBarData = series.getExtraValues();
        for (int i = 0; i < xData.length; i++) {
  
          StringBuilder sb = new StringBuilder();
          sb.append(xData[i]).append(",");
          sb.append(yData[i]).append(",");
          if (errorBarData != null) {
            sb.append(errorBarData[i]).append(",");
          }
          sb.setLength(sb.length() - 1);
          sb.append(System.getProperty("line.separator"));
  
          // String csv = xDataPoint + "," + yDataPoint + errorBarValue == null ? "" : ("," +
          // errorBarValue) + System.getProperty("line.separator");
          // String csv = + yDataPoint + System.getProperty("line.separator");
          out.write(sb.toString());
        }
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        if (out != null) {
          try {
            out.flush();
            out.close();
          } catch (IOException e) {
            // NOP
          }
        }
      }
    }
docs: Export a Chart series in columns in a CSV file.
  
  @param series
  @param path2Dir - ex. "./path/to/directory/" *make sure you have the '/' on the end