Well, I am creating dumped objects using a ByteArrayOutputStream. And then will write them to MongoDB as an attribute in my documents. When I read it back how can I convert it to a byte array or a Binary without using a toString in the middle?
This is the way I do it now, and I dont think it is safe:
BasicBSONObject temp = (BasicBSONObject) models.get("0");
model = null;
if (temp != null) {
// TODO fix this serialization!
try {
ObjectInputStream ois = new ObjectInputStream(
new ByteArrayInputStream(temp.toString().getBytes()));
} catch (IOException e) {
L.error("unable to read model from string!");
L.error(e.getStackTrace().toString());
}
}