me.edwards.des.util
Class ByteUtil

java.lang.Object
  extended by me.edwards.des.util.ByteUtil

public class ByteUtil
extends java.lang.Object

Utility class for converting Java data structures and primitives into byte arrays, or hexadecimal Strings, or vice-versa.

Created on: Oct 17, 2015 at 9:21:05 AM

Author:
Matthew Edwards

Constructor Summary
ByteUtil()
           
 
Method Summary
static java.lang.String bytesToHex(byte[] bytes)
          Converts a byte array into a hexadecimal String
static int bytesToInt(byte[] bytes)
          Converts a byte array into an integer
static byte[] hexToBytes(java.lang.String hex)
          Converts a hexadecimal String into a byte array
static byte[] intToBytes(int i)
          Converts an integer into a byte array
static byte[] longToBytes(long l)
          Converts a long integer into a byte array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteUtil

public ByteUtil()
Method Detail

intToBytes

public static byte[] intToBytes(int i)
Converts an integer into a byte array

Parameters:
i - Integer to convert
Returns:
Byte array representing the integer

bytesToInt

public static int bytesToInt(byte[] bytes)
Converts a byte array into an integer

Parameters:
bytes - Byte array to convert
Returns:
Integer representing the byte array

longToBytes

public static byte[] longToBytes(long l)
Converts a long integer into a byte array

Parameters:
l - Long integer to convert
Returns:
Byte array representing the long integer

hexToBytes

public static byte[] hexToBytes(java.lang.String hex)
Converts a hexadecimal String into a byte array

Parameters:
hex - Hex String to convert
Returns:
Byte array representing the hexadecimal String

bytesToHex

public static java.lang.String bytesToHex(byte[] bytes)
Converts a byte array into a hexadecimal String

Parameters:
bytes - Byte array to convert
Returns:
A hexadecimal String representing the byte array