Class BinaryUtil


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

      Constructors 
      Constructor Description
      BinaryUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] copy​(byte[] bytes)  
      static byte[] encodeUint16​(int value)  
      static byte[] fromHex​(java.lang.String hex)  
      static int getUint16​(byte[] bytes)
      Read 2 bytes as a big endian unsigned 16-bit integer.
      static long getUint32​(byte[] bytes)
      Read 4 bytes as a big endian unsigned 32-bit integer.
      static short getUint8​(byte b)
      Read one byte as an unsigned 8-bit integer.
      static byte singleFromHex​(java.lang.String hex)
      Parse a single byte from two hexadecimal characters.
      static java.lang.String toHex​(byte[] bytes)  
      • Methods inherited from class java.lang.Object

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

      • BinaryUtil

        public BinaryUtil()
    • Method Detail

      • copy

        public static byte[] copy​(byte[] bytes)
      • toHex

        public static java.lang.String toHex​(byte[] bytes)
        Parameters:
        bytes - Bytes to encode
      • fromHex

        public static byte[] fromHex​(java.lang.String hex)
        Parameters:
        hex - String of hexadecimal digits to decode as bytes.
      • singleFromHex

        public static byte singleFromHex​(java.lang.String hex)
        Parse a single byte from two hexadecimal characters.
        Parameters:
        hex - String of hexadecimal digits to decode as bytes.
      • getUint8

        public static short getUint8​(byte b)
        Read one byte as an unsigned 8-bit integer.

        Result is of type Short because Java don't have unsigned types.

        Returns:
        A value between 0 and 255, inclusive.
      • getUint16

        public static int getUint16​(byte[] bytes)
        Read 2 bytes as a big endian unsigned 16-bit integer.

        Result is of type Int because Java don't have unsigned types.

        Returns:
        A value between 0 and 2^16- 1, inclusive.
      • getUint32

        public static long getUint32​(byte[] bytes)
        Read 4 bytes as a big endian unsigned 32-bit integer.

        Result is of type Long because Java don't have unsigned types.

        Returns:
        A value between 0 and 2^32 - 1, inclusive.
      • encodeUint16

        public static byte[] encodeUint16​(int value)