public synchronized void writeData(ByteBuffer inBuffer, int len) throws ClosedChannelException { checkBuffer(); len = len > inBuffer.remaining() ? inBuffer.remaining() : len; if (dataPos + len > buf.length) { throw new BufferOverflowException(); } for (int i = 0; i < len; i++) { buf[dataPos + i] = inBuffer.get(); } dataPos += len; }
/** * Write data to this packet. * * @param inarray input array of data * @param off the offset of data to write * @param len the length of data to write * @throws ClosedChannelException */ synchronized void writeData(byte[] inarray, int off, int len) throws ClosedChannelException { checkBuffer(); if (dataPos + len > buf.length) { throw new BufferOverflowException(); } System.arraycopy(inarray, off, buf, dataPos, len); dataPos += len; }
/** * Write data to this packet. * * @param inarray input array of data * @param off the offset of data to write * @param len the length of data to write * @throws ClosedChannelException */ synchronized void writeData(byte[] inarray, int off, int len) throws ClosedChannelException { checkBuffer(); if (dataPos + len > buf.length) { throw new BufferOverflowException(); } System.arraycopy(inarray, off, buf, dataPos, len); dataPos += len; }
/** * Write checksums to this packet * * @param inarray input array of checksums * @param off the offset of checksums to write * @param len the length of checksums to write * @throws ClosedChannelException */ synchronized void writeChecksum(byte[] inarray, int off, int len) throws ClosedChannelException { checkBuffer(); if (len == 0) { return; } if (checksumPos + len > dataStart) { throw new BufferOverflowException(); } System.arraycopy(inarray, off, buf, checksumPos, len); checksumPos += len; }
/** * Write data to this packet. * * @param inarray input array of data * @param off the offset of data to write * @param len the length of data to write * @throws ClosedChannelException */ synchronized void writeData(byte[] inarray, int off, int len) throws ClosedChannelException { checkBuffer(); if (dataPos + len > buf.length) { throw new BufferOverflowException(); } System.arraycopy(inarray, off, buf, dataPos, len); dataPos += len; }
/** * Write checksums to this packet * * @param inarray input array of checksums * @param off the offset of checksums to write * @param len the length of checksums to write * @throws ClosedChannelException */ public synchronized void writeChecksum(byte[] inarray, int off, int len) throws ClosedChannelException { checkBuffer(); if (len == 0) { return; } if (checksumPos + len > dataStart) { throw new BufferOverflowException(); } System.arraycopy(inarray, off, buf, checksumPos, len); checksumPos += len; }
/** * Write checksums to this packet * * @param inarray input array of checksums * @param off the offset of checksums to write * @param len the length of checksums to write * @throws ClosedChannelException */ synchronized void writeChecksum(byte[] inarray, int off, int len) throws ClosedChannelException { checkBuffer(); if (len == 0) { return; } if (checksumPos + len > dataStart) { throw new BufferOverflowException(); } System.arraycopy(inarray, off, buf, checksumPos, len); checksumPos += len; }