| | |
| | | |
| | | public ByteHolder(int bufferSize) |
| | | { |
| | | System.out.print("ByteHolder(bufferSize:"+bufferSize+")"); |
| | | |
| | | this.buffer = new byte[bufferSize]; |
| | | } |
| | | |
| | |
| | | |
| | | public void sliceInto(byte[] dest, int length) |
| | | { |
| | | //System.out.println(); |
| | | System.arraycopy(this.buffer, 0, dest, 0, length); |
| | | // 往前挪length个位 |
| | | System.arraycopy(this.buffer, length, this.buffer, 0, this.size - length); |
| | |
| | | int l = this.buffer[position + 1] & 0xff; |
| | | return ((h << 8) | l) & 0xffff; |
| | | } |
| | | // ✅ 添加这个方法 |
| | | public byte[] peek(int length) { |
| | | if (size < length) return null; |
| | | return Arrays.copyOfRange(this.buffer, 0, length); |
| | | } |
| | | } |