This test case demonstrates that CharBuffer.charAt throws IndexOutOfBoundsException for indexes that should be well within the buffer.
import java.nio.*;
import java.nio.charset.*;
public class Test
{
public static void main(String[] args) throws Exception {
char[] someChars = new char[5];
for (int i=0; i<5; i++)
someChars[i] = (char)(97 + i);
CharBuffer cb = CharBuffer.wrap(someChars);
char c = cb.charAt(1);
}
}
import java.nio.*;
import java.nio.charset.*;
public class Test
{
public static void main(String[] args) throws Exception {
char[] someChars = new char[5];
for (int i=0; i<5; i++)
someChars[i] = (char)(97 + i);
CharBuffer cb = CharBuffer.wrap(someChars);
char c = cb.charAt(1);
}
}
- duplicates
-
JDK-4510323 (bf) CharSequence views of CharBuffers do not work
-
- Closed
-