StringCharBuffer.subSequence(int start,int end) does not represent specified subsequence of buffer, relative to the current position.
String source = "This is the string used to test subSequence() method";
StringCharBuffer c = (StringCharBuffer)(CharBuffer.wrap(source));
// Set the position of c to some value.
int position = 5;
c.position(position);
int start = 5;
int end = 10;
CharBuffer cNew = (CharBuffer)(c.subSequence(start,end));
if(!source.substring(position+start,position+end).equals(cNew.toString())) {
System.out.println("error");
System.out.println("New buffer contains: "+cNew.toString());
System.out.println("Expected: "+source.substring(position+start,position+end));
}
results in :
error
New buffer contains: is th
Expected: e str
###@###.### 2001-10-04
Since StringCharBuffer is no longer public class, this bug cannot be verified.
Bug 4511104 has been created that addresses CharBuffer's issues. (see 4415483)