Hmm, will this always work? What if an object doesn't have a toString() implementation. Maybe something like this would be better: http://stackoverflow.com/questions/3736058/java-object-to-byte-and-byte-to-object-converter-for-tokyo-cabinet