SourceForge Jpcap

net.sourceforge.jpcap.util
Class HexHelper

java.lang.Object
  extended by net.sourceforge.jpcap.util.HexHelper

public class HexHelper
extends Object

Functions for formatting and printing binary data in hexadecimal.

Version:
$Revision: 1.1 $
Author:
Patrick Charles and Jonas Lehmann, Esmond Pitt
Last modified by:
$Author: esmondpitt $
Last modified at:
$Date: 2008/08/21 02:59:23 $

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 String toQuadString(int i)
          Convert an int (32 bits in Java) to a decimal quad of the form aaa.bbb.ccc.ddd.
static String toString(byte b)
          Convert a single byte into a string representing its hex value.
static String toString(byte[] bytes)
          Returns a text representation of a byte array.
static 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 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 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 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 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.

Copyright © Patrick Charles & Jonas Lehmann, 2001; Esmond Pitt, 2008.