Class ByteConversions


  • public final class ByteConversions
    extends Object
    Convenience methods for converting data types to and from byte arrays.
    • Method Detail

      • toBytes

        public static byte[] toBytes​(short value,
                                     ByteOrder byteOrder)
      • toBytes

        public static byte[] toBytes​(short[] values,
                                     ByteOrder byteOrder)
      • toBytes

        public static byte[] toBytes​(int value,
                                     ByteOrder byteOrder)
      • toBytes

        public static byte[] toBytes​(int[] values,
                                     ByteOrder byteOrder)
      • toBytes

        public static byte[] toBytes​(float value,
                                     ByteOrder byteOrder)
      • toBytes

        public static byte[] toBytes​(float[] values,
                                     ByteOrder byteOrder)
      • toBytes

        public static byte[] toBytes​(double value,
                                     ByteOrder byteOrder)
      • toBytes

        public static byte[] toBytes​(double[] values,
                                     ByteOrder byteOrder)
      • toShort

        public static short toShort​(byte[] bytes,
                                    ByteOrder byteOrder)
      • toShorts

        public static short[] toShorts​(byte[] bytes,
                                       ByteOrder byteOrder)
      • toUInt16

        public static int toUInt16​(byte[] bytes,
                                   ByteOrder byteOrder)
      • toUInt16

        public static int toUInt16​(byte[] bytes,
                                   int offset,
                                   ByteOrder byteOrder)
      • toUInt16s

        public static int[] toUInt16s​(byte[] bytes,
                                      ByteOrder byteOrder)
      • toInt

        public static int toInt​(byte[] bytes,
                                ByteOrder byteOrder)
      • toInt

        public static int toInt​(byte[] bytes,
                                int offset,
                                ByteOrder byteOrder)
      • toInts

        public static int[] toInts​(byte[] bytes,
                                   ByteOrder byteOrder)
      • toFloat

        public static float toFloat​(byte[] bytes,
                                    ByteOrder byteOrder)
      • toFloats

        public static float[] toFloats​(byte[] bytes,
                                       ByteOrder byteOrder)
      • toDouble

        public static double toDouble​(byte[] bytes,
                                      ByteOrder byteOrder)
      • toDoubles

        public static double[] toDoubles​(byte[] bytes,
                                         ByteOrder byteOrder)
      • toRational

        public static RationalNumber toRational​(byte[] bytes,
                                                ByteOrder byteOrder,
                                                boolean unsignedType)
        Interprets the content of a specified bytes array to create an instance of the RationalNumber class.
        Parameters:
        bytes - a valid array dimensioned to at least 8.
        byteOrder - the byte order for integer conversion
        unsignedType - indicates whether the extracted value is an unsigned type.
        Returns:
        a valid instance
      • toRationals

        public static RationalNumber[] toRationals​(byte[] bytes,
                                                   ByteOrder byteOrder,
                                                   boolean unsignedType)