search

Home  >  Q&A  >  body text

java - Related questions about ByteBuffer

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 !

怪我咯怪我咯2790 days ago647

reply all(2)I'll reply

  • 滿天的星座

    滿天的星座2017-05-16 13:31:23

    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.

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-16 13:31:23

    ByteBuffer.wrap(yourString.getBytes(Charset));

    reply
    0
  • Cancelreply