net.sourceforge.jpcap.util
Class HexHelper

java.lang.Object
  extended bynet.sourceforge.jpcap.util.HexHelper

public class HexHelper
extends java.lang.Object

Functions for formatting and printing binary data in hexadecimal.


Constructor Summary
HexHelper()
           
 
Method Summary
static char nibbleToDigit(byte x)
          Converts the lower four bits of a byte into the ascii digit which represents its hex value.
static java.lang.String toQuadString(int i)
          Convert an int (32 bits in Java) to a decimal quad of the form aaa.bbb.ccc.ddd.
static java.lang.String toString(byte b)
          Convert a single byte into a string representing its hex value.
static java.lang.String toString(byte[] bytes)
          Returns a text representation of a byte array.
static java.lang.String toString(int i)
          Convert an int to a hexadecimal 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

toQuadString

public static java.lang.String toQuadString(int i)
Convert an int (32 bits in Java) to a decimal quad of the form aaa.bbb.ccc.ddd.


toString

public static java.lang.String toString(int i)
Convert an int to a hexadecimal string.


nibbleToDigit

public static char nibbleToDigit(byte x)
Converts the lower four bits of a byte into the ascii digit which represents its hex value. For example: nibbleToDigit(10) produces 'a'.


toString

public static java.lang.String toString(byte b)
Convert a single byte into a string representing its hex value. i.e. -1 -> "ff"

Parameters:
b - the byte to convert.
Returns:
a string containing the hex equivalent.

toString

public static java.lang.String toString(byte[] bytes)
Returns a text representation of a byte array.

Parameters:
bytes - a byte array
Returns:
a string containing the hex equivalent of the bytes.