Class ByteUtil


  • public final class ByteUtil
    extends java.lang.Object
    Utility package for byte manipulation.
    Since:
    1.0
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] randomBytes()
      Random array of bytes with a random length.
      static byte[] randomBytes​(int length)
      Get a random array of bytes with the length specified.
      static byte[] randomBytes​(java.util.Random r)
      Random array of bytes with a random length.
      static byte[] randomBytes​(java.util.Random r, int length)
      For those that like the random bytes to be created and returned.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • randomBytes

        public static byte[] randomBytes​(java.util.Random r,
                                         int length)
        For those that like the random bytes to be created and returned. Uses the Random.nextBytes(byte[]) method to generate the random data.
        Parameters:
        r - to keep the same randomizer just pass it in..
        length - size of the array of random data returned.
        Returns:
        byte array of random data.
      • randomBytes

        public static byte[] randomBytes​(int length)
        Get a random array of bytes with the length specified.
        Parameters:
        length - the size of the byte array returned.
        Returns:
        random array of bytes with the length specified.
      • randomBytes

        public static byte[] randomBytes​(java.util.Random r)
        Random array of bytes with a random length. The length should be no greater that 4k.
        Parameters:
        r - uses the randomizer provided to generate the random data.
        Returns:
        a byte array no bigger than 4k filled with random data.
      • randomBytes

        public static byte[] randomBytes()
        Random array of bytes with a random length. The length should be no greater that 4k.
        Returns:
        a byte array no bigger than 4k filled with random data.