@Test
  public void testWriteRead() {
    DataSetIterator iter = new IrisDataSetIterator(150, 150);
    String irisData = "irisData.dat";

    DataSet freshDataSet = iter.next(150);

    SerializationUtils.saveObject(freshDataSet, new File(irisData));

    DataSet readDataSet = SerializationUtils.readObject(new File(irisData));

    assertEquals(freshDataSet.getFeatureMatrix(), readDataSet.getFeatureMatrix());
    assertEquals(freshDataSet.getLabels(), readDataSet.getLabels());
    try {
      FileUtils.forceDelete(new File(irisData));
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Esempio n. 2
0
 public static void main(String[] args) {
   Person p = (Person) SerializationUtils.readObject();
   System.out.println("name=" + p.getName());
 }