io2 = self.getRuntime().fastGetClass("StringIO").callMethod(context, "new");
iox = new IOOutputStream(io2);
} else {
iox = new IOOutputStream(io);
}
Serializer ser = new JRubySerializer(new EmitterImpl(iox,cfg),new ResolverImpl(),cfg);
try {
ser.open();
Representer r = new JRubyRepresenter(ser, cfg);
for(Iterator iter = objs.getList().iterator();iter.hasNext();) {
r.represent(iter.next());
}
ser.close();
} catch(IOException e) {
throw self.getRuntime().newIOErrorFromException(e);
}
if(null == io) {
io2.callMethod(context, "rewind");