What is the fastest way to convert java.nio.ByteBuffer ato (newly created) CharBuffer bor char[] b.
It is important that a[i] == b[i]. This means that they do not a[i]and a[i+1]together make up the meaning of b[j]what getChar(i)will be done, but the meanings must be “disseminated”.
byte a[] = { 1,2,3, 125,126,127, -128,-127,-126 }
char b[] = { 1,2,3, 125,126,127, 128, 129, 130 }
Note that it byte:-128has the same (lower 8) bits as char:128. Therefore, I assume that the “best” interpretation will be the same as I noted above, because the bit is the same.
After that, I will also need a translation the other way around : the most efficient way to get it back char[]or java.nio.CharBufferback to java.nio.ByteBuffer.
source
share