Code example for CharBuffer

Methods: limit, rewind

0
    } 
 
 
    private void resizeCharBuffer() throws IOException { 
        int maxSize = getCharBufferMaxSize();
        if (cb.limit() >= maxSize) {
            throw new IOException(sm.getString("message.bufferTooSmall"));
        } 
 
        long newSize = cb.limit() * 2;
        if (newSize > maxSize) {
            newSize = maxSize;
        } 
 
        // Cast is safe. newSize < maxSize and maxSize is an int 
        CharBuffer newBuffer = CharBuffer.allocate((int) newSize);
        cb.rewind();
        newBuffer.put(cb);
        cb = newBuffer;
    }