org.brains2b.util
Class HexHelper

java.lang.Object
  extended byorg.brains2b.util.HexHelper

public class HexHelper
extends java.lang.Object

HexHelper decodes and encodes to hexadecimal values.

Version:
0.10 [2-aug-2006]
Author:
dennis@brains2b.nl

Constructor Summary
HexHelper()
           
 
Method Summary
static byte[] decode(java.lang.String s)
          decode a hexidecimal string into an array of bytes
static java.lang.String encode(byte[] b)
          encode an array of bytes into a hexidecimal String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HexHelper

public HexHelper()
Method Detail

encode

public static final java.lang.String encode(byte[] b)
encode an array of bytes into a hexidecimal String

The string is supplied without any prefix

Parameters:
b - byte[], the array to encode
Returns:
the hexidecimal String
Throws:
java.lang.NullPointerException - if no bytes were supplied

decode

public static final byte[] decode(java.lang.String s)
decode a hexidecimal string into an array of bytes

If it is prefixed with '0x' this will be removed first.

If the String has an odd length '0' will be prepended

Parameters:
s - String, the hexidecimal String to decode
Returns:
An array of bytes
Throws:
NullPointerException, - if String is null