How to convert a string into ByteBuffer in Java and store it in ByteBuffer in binary form, because it needs to be sent to C++Please give me a detailed Java method, I don’t know much about ByteBuffer, thank you !
走同样的路,发现不同的人生
You can first convert the string into a byte array byte[], and then use the put method of ByteBuffer to write it into the buffer.
ByteBuffer.wrap(yourString.getBytes(Charset));
You can first convert the string into a byte array byte[], and then use the put method of ByteBuffer to write it into the buffer.