code: public static <Type extends DataSet<Type>> void writeData(DataSet<Type> dataset, OutputStream outRaw, FloatStorageMethod fpStore) throws IOException
      {
          fpStore = FloatStorageMethod.getMethod(dataset, fpStore);
          
          DataWriter.DataSetType type;
          CategoricalData predicting;
          if(dataset instanceof ClassificationDataSet)
          {
              type = DataWriter.DataSetType.CLASSIFICATION;
              predicting = ((ClassificationDataSet)dataset).getPredicting();
          }
          else if(dataset instanceof RegressionDataSet)
          {
              type = DataWriter.DataSetType.REGRESSION;
              predicting = null;
          }
          else
          {
              type = DataWriter.DataSetType.SIMPLE;
              predicting = null;
          }
          
          DataWriter dw = getWriter(outRaw, dataset.getCategories(), dataset.getNumNumericalVars(), predicting, fpStore, type);
          
          //write out all the datapoints
          for(int i = 0; i < dataset.size(); i++)
          {
              double label = 0;
              if (dataset instanceof ClassificationDataSet)
                  label = ((ClassificationDataSet) dataset).getDataPointCategory(i);
              else if (dataset instanceof RegressionDataSet)
                  label = ((RegressionDataSet) dataset).getTargetValue(i);
              dw.writePoint(dataset.getWeight(i), dataset.getDataPoint(i), label);
          }
          
          dw.finish();
          outRaw.flush();
      }
docs: This method writes out a JSAT dataset to a binary format that can be read
  in again later, and could be read in other languages.<br>
  <br>
  The format that is used will understand both
  {@link ClassificationDataSet} and {@link RegressionDataSet} datasets as
  special cases, and will store the target values in the binary file. When
  read back in, they can be returned as their original dataset type, or
  treated as normal fields as a {@link SimpleDataSet}.
  
  @param <Type>
  @param dataset the dataset to write out to a binary file
  @param outRaw the raw output stream, the caller should provide a buffered
  stream.
  @param fpStore the storage method of storing floating point values, which
  may result in a loss of precision depending on the method chosen.
  @throws IOException