M
M
maaGames2018-07-14 11:13:14
Java
maaGames, 2018-07-14 11:13:14

Write/Read data to byte array (not serialization)?

You need to save / read data into an array of bytes for transmission over Wi-Fi.
I do not want to use json and the like because of the time spent on encoding / parsing. It is required to ensure transmission (and parsing) of at least 30 blocks per second. Moreover, the block size limits the possibilities. Those. 10 kilobyte json can be parsed without problems with such a frequency, but if it is already a megabyte in size or 10 megabytes ... Therefore, you just need to make a binary array storing integers, real numbers and strings in a fixed order. It seems like I figured out how to store-read numbers by specifying the offset in the byte array and converting the byte array into an array of numbers. And here is how to save-read the lines I can not understand.
* I am very superficially familiar with java, I would like to find some analogue of Cip plus read / write to a stream.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Mirilaczvili, 2018-07-14
@2ord

Strings can be serialized encoded to end with '\0', AsciiZ.
In general, ProtoBuf, MsgPack are often used for such private purposes.
But first you need to make sure that serialization to JSON is the bottleneck.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question