Class ByteArrayTools


  • public class ByteArrayTools
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteArrayTools()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] concat​(byte[] array1, byte[] array2)  
      static byte[] copy​(byte[] bytes)
      Make a copy of bytes.
      static byte[] copy​(byte[] bytes, int offset, int length)
      Copy length bytes from bytes starting at from.
      static int indexOf​(byte[] source, int sourceOffset, int sourceLen, byte[] pattern, int patternOffset, int patternLen, int fromIndex)
      Search index of pattern in source.
      static boolean startsWith​(byte[] bytes, byte[] pattern)
      true if bytes starts with the byte sequence defined in pattern.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ByteArrayTools

        public ByteArrayTools()
    • Method Detail

      • concat

        public static byte[] concat​(byte[] array1,
                                    byte[] array2)
      • copy

        public static byte[] copy​(byte[] bytes)
        Make a copy of bytes.
        Parameters:
        bytes - byte[] to be copied
        Returns:
        A copy of bytes
      • copy

        public static byte[] copy​(byte[] bytes,
                                  int offset,
                                  int length)
        Copy length bytes from bytes starting at from.
        Parameters:
        bytes - byte[] to be copied
        offset - starting position to copy from
        length - number of bytes
        Returns:
        A copy of bytes
      • indexOf

        public static int indexOf​(byte[] source,
                                  int sourceOffset,
                                  int sourceLen,
                                  byte[] pattern,
                                  int patternOffset,
                                  int patternLen,
                                  int fromIndex)
        Search index of pattern in source. Algorithm from java.lang.String
        Parameters:
        source -
        sourceOffset -
        sourceLen -
        pattern -
        patternOffset -
        patternLen -
        fromIndex -
        Returns:
        The index of the first occurrence of pattern or -1.
      • startsWith

        public static boolean startsWith​(byte[] bytes,
                                         byte[] pattern)
        true if bytes starts with the byte sequence defined in pattern.
        Parameters:
        bytes -
        pattern -
        Returns:
        true if bytes starts with the byte sequence defined in pattern.