return new ByteArrayInputStream(baos.toByteArray());
}
public long sizeOf(Object obj) {
try {
CountingOutputStream c = new CountingOutputStream(new NullOutputStream());
ObjectOutputStream stream = new ObjectOutputStream(c);
stream.writeObject(obj);
stream.close();
return c.getBytesWritten();
} catch (IOException ex) {
throw new IllegalStateException("I/O exception " + ex.getClass().getName() + " can't happen, yet did: "
+ ex.getMessage());
}
}