You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sure. View objects of fixed size are just raw buffers where data is laid out sequentially without any padding, pointers etc. For example, the following schema:
results in a buffer where 6 bytes of UTF8 string are followed by one byte integer, 7 bytes total. This sort of buffer or byte array can be created in any language supporting byte manipulations. In C/C++ one can just use structs with #pragma pack(1) directive to disable alignment. I am not sure what would be the easiest way of doing the same in Java, but it does have a number of primitives working with bytes, including ByteBuffer class, so something along the following lines should work:
...
// get utf8 bytes of our name string;byte[] name = "Arthur".getBytes("UTF-8");
// encode age as one bytebyteage = 10;
// allocate 7 bytes of bufferByteBufferbuffer = ByteBuffer.allocate(7);
// write the name at the beginning buffer.put(name);
// write age as the last bytebuffer.put(6, age);
...
Was curious if it is possible to convert Java objects into a
View
and sent to browser for JavaScript consumption? Any examples?The text was updated successfully, but these errors were encountered: