serialization - Java Serializable objects -


this question has answer here:

i have started work sending data on sockets past few weeks. started sending multiple strings data , parsing data floats or ever type needed for. on time noticed client start slow down because reading , converting multiple strings , using them while server dishing them out. began sending serializable objects work , great have questions them.

public class packet implements serializable{     private static final long serialversionuid = -7896044384334791233l;     //data here } 

a class send looks data want send. removing serial versionuid creates error. serialversionuid , if same in objects sending why 1 long necessary program work?

it's way format of data is. if delete field class, should change serialversionuuid or consumers of object may read incorrectly.

check out answer.

why generate long serialversionuid instead of simple 1l?

see link see incompatible changes, deleting fields. http://docs.oracle.com/javase/6/docs/platform/serialization/spec/version.html

also can override default method java used serialize object writeobject , readobject. useful if know compressing object data (for example) lead less network traffic between components. or maybe there custom way want send data more optimal default java way.

see answer. java custom serialization


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -