But one query, when we seriliaze as a byte buffer, how to know the size required for writing this consecutive null value?  It may be located in between also and many such occurences could occur, like
a, b, null, null, c, d, null, d, null, e, null, null,f like this.
Am not saying this cannot be done, the thing is we may have to iterate thro the Array and find out such occurences and calculate the bytes needed to store them apart from the double null  byte at the end, which will happen in any case.