info.aduna.text
Class EncodingUtil

java.lang.Object
  extended by info.aduna.text.EncodingUtil

public class EncodingUtil
extends java.lang.Object

Utility methods for encoding and decoding values in various encoding formats.


Constructor Summary
EncodingUtil()
           
 
Method Summary
static java.lang.String binary2hex(byte[] bytes)
          Translates a binary value (in the form of a byte array) to its hexadecimal value.
static byte[] hex2binary(java.lang.String hexString)
          Translates an hexadecimal value to binary (in the form of a byte array).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncodingUtil

public EncodingUtil()
Method Detail

binary2hex

public static java.lang.String binary2hex(byte[] bytes)
Translates a binary value (in the form of a byte array) to its hexadecimal value. Each byte is translated to a two-digit hexadecimal value, e.g. the byte value 10 is translated to 0A.

Parameters:
bytes - The binary value to translate to hexadecimal.
Returns:
The hexadecimal value of the binary input.

hex2binary

public static byte[] hex2binary(java.lang.String hexString)
Translates an hexadecimal value to binary (in the form of a byte array). Every two hexadecimal digits are translated to a single byte, e.g. the hexadecimal value 0A is translated to a single byte with the value 10.

Parameters:
hexString - The hexadecimal value to translate to binary.
Returns:
The binary value to the hexadecimal input.
Throws:
java.lang.NumberFormatException - If the supplied hexString does not represent an hexadecimal value.


Copyright © 2010 Aduna. All Rights Reserved.