IoBuffer { @Override public boolean equals(Object ob) { if (this == ob) { return true; } if (!(ob instanceof IoBuffer)) { return false; } IoBuffer that = (IoBuffer) ob; if (this.remaining() != that.remaining()) { return false; } int p = this.position(); int q = that.position(); while (this.hasRemaining() && that.hasRemaining()) { if (this.get() != that.get()) { this.position(p); that.position(q); return false; } } this.position(p); that.position(q); return true; } private  IoBuffer(); static IoBuffer allocate(int capacity); static IoBuffer allocateDirect(int capacity); static IoBuffer newInstance(); static IoBuffer wrap(byte[]... arrays); static IoBuffer wrap(byte[] array, int offset, int length); static IoBuffer wrap(ByteBuffer... buffers); IoBuffer add(ByteBuffer... buffers); byte[] array(); int arrayOffset(); InputStream asInputStream(); IoBuffer asReadOnlyBuffer(); int capacity(); IoBuffer clear(); IoBuffer compact(); IoBuffer duplicate(); @Override boolean equals(Object ob); IoBuffer extend(int size); IoBuffer flip(); byte get(); IoBuffer get(byte[] dst); IoBuffer get(byte[] dst, int offset, int length); byte get(int index); char getChar(); char getChar(int index); double getDouble(); double getDouble(int index); float getFloat(); float getFloat(int index); int getInt(); int getInt(int index); long getLong(); long getLong(int index); short getShort(); long getShort(int index); @Override int hashCode(); boolean hasRemaining(); boolean isDirect(); boolean isReadOnly(); int limit(); void limit(int newLimit); void mark(); ByteOrder order(); IoBuffer order(ByteOrder bo); int position(); void position(int newPosition); IoBuffer put(byte b); IoBuffer put(byte[] src); IoBuffer put(ByteBuffer src); IoBuffer put(IoBuffer src); IoBuffer put(byte[] src, int offset, int length); IoBuffer put(int index, byte value); IoBuffer putChar(char value); IoBuffer putChar(int index, char value); IoBuffer putDouble(double value); IoBuffer putDouble(int index, double value); IoBuffer putFloat(float value); IoBuffer putFloat(int index, float value); IoBuffer putInt(int value); IoBuffer putInt(int index, int value); IoBuffer putLong(int index, long value); IoBuffer putLong(long value); IoBuffer putShort(int index, short value); IoBuffer putShort(short value); int remaining(); IoBuffer reset(); IoBuffer rewind(); IoBuffer slice(); @Override String toString();  }
@Test public void testEquals() { String h = "Hello"; String w = "World"; IoBuffer hw1b = IoBuffer.wrap((h + w).getBytes()); IoBuffer wh1b = IoBuffer.wrap((w + h).getBytes()); IoBuffer hw2b = IoBuffer.newInstance(); hw2b.add(ByteBuffer.wrap(h.getBytes())); hw2b.add(ByteBuffer.wrap(w.getBytes())); assertEquals(hw2b, hw1b); Assert.assertThat(wh1b, is(not(hw1b))); }