Class BytesUtil

java.lang.Object
org.seppiko.commons.utils.BytesUtil

public class BytesUtil
extends java.lang.Object
Bytes Util
Author:
Leonard Woo
  • Constructor Summary

    Constructors
    Constructor Description
    BytesUtil()  
  • Method Summary

    Modifier and Type Method Description
    static double bytesToDouble​(byte[] bytes)
    Convert byte array to double
    static float bytesToFloat​(byte[] bytes)
    Convert byte array to float
    static int bytesToInt​(byte[] bytes)
    Convert byte array to int
    static long bytesToLong​(byte[] bytes)
    Convert byte array to long
    static short bytesToShort​(byte[] bytes)
    Convert byte array to short
    static byte[] doubleToBytes​(double d)
    Convert double to byte array
    static byte[] floatToBytes​(float f)
    Convert float to byte array
    static byte[] intToBytes​(int i)
    Convert int to byte array
    static byte[] longToBytes​(long l)
    Convert long to byte array
    static byte[] shortToBytes​(short s)
    Convert short to byte array

    Methods inherited from class java.lang.Object

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

    • BytesUtil

      public BytesUtil()
  • Method Details

    • longToBytes

      public static byte[] longToBytes​(long l)
      Convert long to byte array
      Parameters:
      l - long number
      Returns:
      byte array
    • bytesToLong

      public static long bytesToLong​(byte[] bytes)
      Convert byte array to long
      Parameters:
      bytes - byte array
      Returns:
      long number
    • intToBytes

      public static byte[] intToBytes​(int i)
      Convert int to byte array
      Parameters:
      i - int number
      Returns:
      byte array
    • bytesToInt

      public static int bytesToInt​(byte[] bytes)
      Convert byte array to int
      Parameters:
      bytes - byte array
      Returns:
      int number
    • shortToBytes

      public static byte[] shortToBytes​(short s)
      Convert short to byte array
      Parameters:
      s - short number
      Returns:
      byte array
    • bytesToShort

      public static short bytesToShort​(byte[] bytes)
      Convert byte array to short
      Parameters:
      bytes - byte array
      Returns:
      short number
    • doubleToBytes

      public static byte[] doubleToBytes​(double d)
      Convert double to byte array
      Parameters:
      d - double number
      Returns:
      byte array
    • bytesToDouble

      public static double bytesToDouble​(byte[] bytes)
      Convert byte array to double
      Parameters:
      bytes - byte array
      Returns:
      double number
    • floatToBytes

      public static byte[] floatToBytes​(float f)
      Convert float to byte array
      Parameters:
      f - float number
      Returns:
      byte array
    • bytesToFloat

      public static float bytesToFloat​(byte[] bytes)
      Convert byte array to float
      Parameters:
      bytes - byte array
      Returns:
      float number