code: public static void saveData(Map<String, List<double[]>> data, File file) throws IOException {
  
      BufferedWriter bw = new BufferedWriter(new FileWriter(file));
  
      for (Entry<String, List<double[]>> classEntry : data.entrySet()) {
        String classLabel = classEntry.getKey();
        for (double[] arr : classEntry.getValue()) {
          String arrStr = Arrays.toString(arr).replaceAll("[\\]\\[\\s]+", "");
          bw.write(classLabel + "," + arrStr + CR);
        }
      }
  
      bw.close();
    }
docs: Saves the dataset.
  
  @param data the dataset.
  @param file the file handler.
  @throws IOException if error occurs.