Class ArrayUtils

java.lang.Object
is.galia.util.ArrayUtils

public final class ArrayUtils extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<byte[]>
    chunkify(byte[] bytes, int maxChunkSize)
    Splits the given data into chunks no larger than the given size.
    static int
    indexOf(byte[] array, byte[] search, int searchOffset)
     
    static byte[]
    merge(List<byte[]> chunks)
     
    static byte[]
    reverse(byte[] inArray)
     
    static boolean
    startsWith(byte[] haystack, byte[] needle)
     
    static boolean
    startsWith(byte[] haystack, byte[] needle, int haystackOffset)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • chunkify

      public static List<byte[]> chunkify(byte[] bytes, int maxChunkSize)
      Splits the given data into chunks no larger than the given size. The last chunk may be smaller than the others.
      Parameters:
      bytes - Data to chunkify.
      maxChunkSize - Maximum chunk size.
      Returns:
      Chunked data.
    • indexOf

      public static int indexOf(byte[] array, byte[] search, int searchOffset)
      Parameters:
      array - Bytes to search within.
      search - Bytes to search for.
      searchOffset - Offset within array to start the search.
      Returns:
      Offset of the first match, or -1 if not found.
    • merge

      public static byte[] merge(List<byte[]> chunks)
      Parameters:
      chunks - Ordered list of chunks to merge.
      Returns:
      Merged chunks.
    • reverse

      public static byte[] reverse(byte[] inArray)
      Parameters:
      inArray - Array to reverse.
      Returns:
      New reversed array.
    • startsWith

      public static boolean startsWith(byte[] haystack, byte[] needle)
      Parameters:
      haystack - Bytes to search against.
      needle - Bytes to search for.
      Returns:
      Whether haystack starts with needle.
    • startsWith

      public static boolean startsWith(byte[] haystack, byte[] needle, int haystackOffset)
      Parameters:
      haystack - Bytes to search against.
      needle - Bytes to search for.
      haystackOffset - Offset within haystack to start searching.
      Returns:
      Whether haystack starts with needle at the given offset.