I would like to use google protobuf in my project.
The point is that I have to set first byte of very message because of underlying code which rejects or accepts the message based on the first byte and it does not know about protobuf.
So this page says https://developers.google.com/protocol-buffers/docs/proto#scalar that I have to use bytes field that corresponds to ByteString in Java.
bytes May contain any arbitrary sequence of bytes. string ByteString
But I do not know how to create ByteString from int value. I have tried this way:
ByteBuffer eventTypeBuffer = ByteBuffer.allocate(1);
eventTypeBuffer.put(0x1c);
ByteString eventType = ByteString.copyFrom(eventTypeBuffer);
System.out.println(eventType.size() + " " + eventTypeBuffer.array().length);
Header.Builder mh = Header.newBuilder();
mh.setEventType(eventType);
Does not work properly and println gives 0 1