public ResizingByteBuffer setRange(int destination, byte[] newData) {
		if(newData == null)
			return this;
		
		ensureSpaceFor(destination + newData.length);
		for(int i=0;i<newData.length;i++) {
			buf[destination+i]=newData[i];
		}
		if(destination + newData.length > this.index) {
			// if buffer grew, move index back to end of buffer.
			this.index = destination + newData.length;
		}
		return this;
	}