Generator gen = new Generator(1000, 1000);
SimpleFeature f = gen.createFeature(0);
SimpleFeatureMarshaller m = new SimpleFeatureMarshaller();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
m.marshall(f, oos);
byte[] ba = baos.toByteArray();
baos.close();
ByteArrayInputStream bais = new ByteArrayInputStream(ba);