ice.util
Class ByteUtil

java.lang.Object
  extended byice.util.ByteUtil

public class ByteUtil
extends Object

A utility class containing common byte related functionalities.

Version:
1.0
Author:
Jack van Ooststroom

Constructor Summary
ByteUtil()
           
 
Method Summary
static byte[] padOrTruncate(byte[] bytes, int length)
          Pads or truncates the specified bytes to the specified length.
static String toHexadecimalString(byte[] bytes)
          Converts the specified bytes to a hexadecimal string.
 
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

padOrTruncate

public static byte[] padOrTruncate(byte[] bytes,
                                   int length)
                            throws IllegalArgumentException

Pads or truncates the specified bytes to the specified length.

Padding or truncating the bytes is dependent on bytes.length:

Parameters:
bytes - the bytes that need to be either padded or truncated.
length - the required length of the bytes being returned.
Returns:
the padded or truncated bytes.
Throws:
IllegalArgumentException - if the specified length is lesser than 0.

toHexadecimalString

public static String toHexadecimalString(byte[] bytes)

Converts the specified bytes to a hexadecimal string.

Parameters:
bytes - the bytes to be converted.
Returns:
the hexadecimal string representation of the specified bytes.