compare Binary ByteBuffer - Java java.nio

Java examples for java.nio:ByteBuffer

Description

compare Binary ByteBuffer

Demo Code


//package com.java2s;

import java.nio.ByteBuffer;

import java.util.Arrays;

public class Main {
    public static boolean compareBinary(ByteBuffer buf1, ByteBuffer buf2,
            int addr1, int addr2, int len) {
        byte[] b1 = new byte[len];
        byte[] b2 = new byte[len];

        buf1.position(addr1);/* w w  w.j av a2s  .c o m*/
        buf2.position(addr2);

        buf1.get(b1);
        buf2.get(b2);

        return Arrays.equals(b1, b2);
    }
}

Related Tutorials