Android Utililty Methods Byte Array Search

List of utility methods to do Byte Array Search

Description

The list of methods to do Byte Array Search are organized into topic(s).

Method

intsearch(byte[] array, int start, int count, byte value)
Search for a value in the array.
if ((array == null) || (array.length <= start) || (start < 0))
    return -1;
if ((count < 0) || (count > (array.length - start)))
    count = array.length - start;
for (int i = 0; i < count; i++) {
    if (array[start + i] == value)
        return (start + i);
return -1;
intsearch(byte[] array, int start, int count, short value)
\copydoc search(byte[],int,int,byte)
if ((array == null) || (array.length <= start) || (start < 0))
    return -1;
if ((count < 0) || (count > (array.length - start)))
    count = array.length - start;
for (int i = 0; i < count - 1; i++) {
    if (value == bigEndToShort(array, (start + i)))
        return (start + i);
return -1;
intsearch(byte[] needle, byte[] haystack, int from, int to)
search
for (int i = from; i < to - needle.length; i++) {
    boolean ok = true;
    for (int j = 0; j < needle.length; j++) {
        if (needle[j] != haystack[i + j]) {
            ok = false;
            break;
    if (ok) {
        return i;
return -1;