Please introduce a new Java class, say TopologySerializer.  You could then create serializer and deserializer object once, instead for every invocation.