Class LittleEndianBitConverter


  • public class LittleEndianBitConverter
    extends Object
    Implement a converter which converts to/from little-endian byte arrays
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] getBytes​(int value)
      Returns the specified 32-bit unsigned integer value as an array of bytes.
      static byte[] getBytes​(long value)
      Returns the specified 64-bit unsigned integer value as an array of bytes.
      static short toInt16​(byte[] array, int index)
      Returns a 16-bit signed integer converted from two bytes at a specified position in a byte array.
      static int toInt32​(byte[] array, int index)
      Returns a 32-bit signed integer converted from two bytes at a specified position in a byte array.
      static short ToUInt16​(byte[] array, int index)
      Returns a 16-bit unsigned integer converted from two bytes at a specified position in a byte array.
      static int toUInt32​(byte[] array, int index)
      Returns a 32-bit unsigned integer converted from two bytes at a specified position in a byte array.
      static long toUInt64​(byte[] array, int index)
      Returns a 64-bit unsigned integer converted from two bytes at a specified position in a byte array.
    • Method Detail

      • ToUInt16

        public static short ToUInt16​(byte[] array,
                                     int index)
                              throws IOException
        Returns a 16-bit unsigned integer converted from two bytes at a specified position in a byte array.
        Parameters:
        array - Specify an array of bytes.
        index - Specify the starting position.
        Returns:
        Returns a 16-bit unsigned integer formed by two bytes beginning at startIndex.
        Throws:
        IOException
      • toUInt32

        public static int toUInt32​(byte[] array,
                                   int index)
                            throws IOException
        Returns a 32-bit unsigned integer converted from two bytes at a specified position in a byte array.
        Parameters:
        array - Specify an array of bytes.
        index - Specify the starting position.
        Returns:
        Returns a 32-bit unsigned integer formed by two bytes beginning at startIndex.
        Throws:
        IOException
      • toInt32

        public static int toInt32​(byte[] array,
                                  int index)
                           throws IOException
        Returns a 32-bit signed integer converted from two bytes at a specified position in a byte array.
        Parameters:
        array - Specify an array of bytes.
        index - Specify the starting position.
        Returns:
        Returns a 32-bit signed integer formed by two bytes beginning at startIndex.
        Throws:
        IOException
      • toInt16

        public static short toInt16​(byte[] array,
                                    int index)
                             throws IOException
        Returns a 16-bit signed integer converted from two bytes at a specified position in a byte array.
        Parameters:
        array - Specify an array of bytes.
        index - Specify the starting position.
        Returns:
        Returns a 16-bit signed integer formed by two bytes beginning at startIndex.
        Throws:
        IOException
      • toUInt64

        public static long toUInt64​(byte[] array,
                                    int index)
                             throws IOException
        Returns a 64-bit unsigned integer converted from two bytes at a specified position in a byte array.
        Parameters:
        array - Specify an array of bytes.
        index - Specify the starting position.
        Returns:
        Returns a 64-bit unsigned integer formed by two bytes beginning at startIndex.
        Throws:
        IOException
      • getBytes

        public static byte[] getBytes​(long value)
        Returns the specified 64-bit unsigned integer value as an array of bytes.
        Parameters:
        value - Specify the number to convert.
        Returns:
        Returns an array of bytes with length 8.
      • getBytes

        public static byte[] getBytes​(int value)
        Returns the specified 32-bit unsigned integer value as an array of bytes.
        Parameters:
        value - Specify the number to convert.
        Returns:
        Returns an array of bytes with length 4.