Code example for ByteBuffer

Methods: capacity, rewind

0
			} 
			// fire onMessage method 
			this.onMessage(textFrame);
 
		} else { // Regular frame data, add to current frame buffer 
			ByteBuffer frame = ByteBuffer.allocate((this.currentFrame != null ? this.currentFrame.capacity() : 0)
					+ this.buffer.capacity());
			if (this.currentFrame != null) {
				this.currentFrame.rewind();
				frame.put(this.currentFrame);
			} 
			frame.put(newestByte);
			this.currentFrame = frame;
		} 
	} 
 
	private void _readHandshake() throws IOException, NoSuchAlgorithmException { 
		ByteBuffer ch = ByteBuffer.allocate((this.remoteHandshake != null ? this.remoteHandshake.capacity() : 0)
				+ this.buffer.capacity());
		if (this.remoteHandshake != null) {
			this.remoteHandshake.rewind();