Android Byte Array Equal equals(final byte[] pArrayA, final int pOffsetA, final byte[] pArrayB, final int pOffsetB, final int pLength)

Here you can find the source of equals(final byte[] pArrayA, final int pOffsetA, final byte[] pArrayB, final int pOffsetB, final int pLength)

Description

equals

Declaration

public static final boolean equals(final byte[] pArrayA,
            final int pOffsetA, final byte[] pArrayB, final int pOffsetB,
            final int pLength) 

Method Source Code

//package com.java2s;

public class Main {
    public static final boolean equals(final byte[] pArrayA,
            final int pOffsetA, final byte[] pArrayB, final int pOffsetB,
            final int pLength) {
        final int lastIndexA = pOffsetA + pLength;
        if (lastIndexA > pArrayA.length) {
            throw new ArrayIndexOutOfBoundsException(pArrayA.length);
        }//from   ww w.  j  a v  a  2 s .  com

        final int lastIndexB = pOffsetB + pLength;
        if (lastIndexB > pArrayB.length) {
            throw new ArrayIndexOutOfBoundsException(pArrayB.length);
        }

        for (int a = pOffsetA, b = pOffsetB; a < lastIndexA; a++, b++) {
            if (pArrayA[a] != pArrayB[b]) {
                return false;
            }
        }

        return true;
    }
}

Related

  1. constantTimeAreEqual(byte[] a, byte[] b)
  2. equals(byte[] array1, byte[] array2)
  3. equals(byte[] array1, byte[] array2, int length)
  4. equals(byte[] array1, byte[] array2, int length)
  5. equals(byte[] array1, byte[] array2, int length)
  6. equals(final byte[] pArrayA, final int pOffsetA, final byte[] pArrayB, final int pOffsetB, final int pLength)
  7. isEqual(byte[] first, byte[] second)
  8. equalByteArray(byte[] src, byte[] dst)
  9. equalByteArray(byte[] src, int srcOffset, int srcLen, byte[] dst, int dstOffset, int dstLen)