If you want to convert any objects, i.e. instances of classes that you don't control, then you will have to use the Java serialization API to serialize them.
There are a number of implementations of the serialization API available that provide different out put. E.g. you can serialize your instances into XML or YAML instead of the default Java binary format.
You wrote that you wanted specifically serialize the object into bytes, so you should be looking for an implementation of the serialization API to provides some sort of binary output. Kryo seems to be one such library.
The code example that you provided is definitely the simplest way to serialize an object into binary.