Using String.getBytes(Charset ch), allocates a new buffer, in fact it returns a byte[]. Is there a way to avoid this? I’d like to have a reusable byte array and have the strings encoded in this buffer.
Using String.getBytes(Charset ch) , allocates a new buffer, in fact it returns a byte[]
Share
You can use the
CharsetandCharsetEncoderAPIs directly, in particular callingencode(CharBuffer, ByteBuffer, boolean). However, I wouldn’t expect it to end up being particularly pleasant code.