Code example for CharBuffer

Methods: put, remaining

0
	public int read(CharBuffer charBuffer) throws IOException {
		if (buffer == null) {
			throw new IOException("Stream closed");
		} 
 
		int length = charBuffer.remaining();
 
		if (length <= 0) {
			return 0; 
		} 
 
		if (index >= capacity) {
			return -1; 
		} 
 
		if ((index + length) > capacity) {
			length = capacity - index;
		} 
 
		charBuffer.put(buffer, index, length);
 
		index += length;
 
		return length;
	}