public static void main(String[] args) {

    MyDataset dataset = new MyDataset();

    for (int i = 0; i < 20; i++) {
      dataset.intArray.getIntValues()[i] = i;
    }

    // write it
    try {
      FileOutputStream output = new FileOutputStream("examplesData\\Test002.sf");
      SFOutputStream outputStream = new SFOutputStreamJava(output, new DefaultExceptionKeeper());

      outputStream.writeString(dataset.getType());
      dataset.getSFDataObject().writeOnStream(outputStream);

      output.close();

    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }

    dataset = new MyDataset();

    // read it
    try {
      FileInputStream input = new FileInputStream("examplesData\\Test002.sf");
      SFInputStream inputStream = new SFInputStreamJava(input, new DefaultExceptionKeeper());

      /*String type=*/ inputStream.readString();
      dataset.getSFDataObject().readFromStream(inputStream);

      for (int i = 0; i < 20; i++) {
        System.out.println(i + " " + dataset.intArray.getIntValues()[i]);
      }

      input.close();

    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  public static void main(String[] args) {

    // write it
    try {
      FileOutputStream output = new FileOutputStream("testsData/data/Test005.sf");
      SFOutputStream outputStream = new SFOutputStreamJava(output, new DefaultExceptionKeeper());

      outputStream.writeByte(2);
      outputStream.writeByte(3);
      outputStream.writeByte(4);
      outputStream.writeByte(-2);
      outputStream.writeByte(-3);
      outputStream.writeByte(-4);

      output.close();

    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }

    // read it
    try {
      FileInputStream input = new FileInputStream("testsData/data/Test005.sf");
      SFInputStream inputStream = new SFInputStreamJava(input, new DefaultExceptionKeeper());

      for (int i = 0; i < 6; i++) {
        System.out.println(inputStream.readByte());
      }

      input.close();

    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
 @Override
 public void writeOnStream(SFOutputStream stream) {
   stream.writeFloats(floatValues);
 }