B4J Question Serializing with WriteB4XObject

wl

Well-Known Member
Licensed User
Longtime User
Hi,

I'm trying object serialization with the RandomAccess class.

Problem is: there are 3 initialization methods for a RandomAccess class
- first two suppose serialization is to bedone to a file
- the third allows serialization to a byte array

How would I know what the length of a serialized object is before initializing the RandomAccessFile ?

Thanks.
 

wl

Well-Known Member
Licensed User
Longtime User
thanks Erel,

But then the problem remains. When using the RandomAccess class I need initialization (Initialize3) of a byte array to put the serialized object in (but I don't know what the size of the serielized object will be).

I have a work around by initializing a buffer of 64K bytes, do serialization and then reinitialize a new array with the correct size and copy the bytes into it (ByteConverter.ArrayCopy). Then I can use this second array to converted the byte array to a Base64 encoded string.

But I find the arraycopy etc kind of annoying (time consuming ?)

Thanks
 
Upvote 0
Top