public static int indexOf(byte[] array, byte[] target) {
    if (target.length == 0) {
      return 0;
    }

    outer:
    for (int i = 0; i < array.length - target.length + 1; i++) {
      for (int j = 0; j < target.length; j++) {
        if (array[i + j] != target[j]) {
          continue outer;
        }
      }
      return i;
    }
    return -1;
  }
@Test
  public void testIndexOf() {
    byte[] array = new byte[] {(byte) 0x9b, 0, 0x18, 0x65, 0x2e, (byte) 0xf3};
    assertEquals(0, IOUtils.indexOf(array, new byte[] {}));
    assertEquals(0, IOUtils.indexOf(array, new byte[] {(byte) 0x9b, 0}));
    assertEquals(2, IOUtils.indexOf(array, new byte[] {0x18, 0x65, 0x2e}));
    assertEquals(4, IOUtils.indexOf(array, new byte[] {0x2e, (byte) 0xf3}));
    assertEquals(-1, IOUtils.indexOf(array, new byte[] {0x2e, (byte) 0xf3, 0x31}));
    assertEquals(-1, IOUtils.indexOf(array, new byte[] {0x31}));
  }