com.sun.sgs.impl.sharedutil
Class HexDumper

java.lang.Object
  extended by com.sun.sgs.impl.sharedutil.HexDumper

public final class HexDumper
extends Object

Utility class for converting a byte array to a hex-formatted string.


Method Summary
static String format(byte[] bytes)
          Returns a string constructed with the contents of the byte array converted to hex format.
static String format(byte[] bytes, int limit)
          Returns a string constructed with the contents of the byte array converted to hex format.
static String format(ByteBuffer buf)
          Returns a string constructed with the contents of the ByteBuffer converted to hex format.
static String format(ByteBuffer buf, int limit)
          Returns a string constructed with the contents of the ByteBuffer converted to hex format.
static byte[] fromHexString(String hexString)
          Returns a byte array constructed with the contents of the given string, which contains a series of byte values in hex format.
static String toHexString(BigInteger bigInt)
          Returns the specified bigInt as a hex-formatted string.
static String toHexString(byte[] bytes)
          Returns a string constructed with the contents of the byte array converted to hex format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

format

public static String format(byte[] bytes)
Returns a string constructed with the contents of the byte array converted to hex format. The entire string is enclosed in square brackets, and the octets are separated by a single space character.

Parameters:
bytes - a byte array to format
Returns:
the contents of the byte array as a hex-formatted string

format

public static String format(byte[] bytes,
                            int limit)
Returns a string constructed with the contents of the byte array converted to hex format. The entire string is enclosed in square brackets, and the octets are separated by a single space character.

Parameters:
bytes - a byte array to format
limit - the maximum number of bytes to format, or 0 meaning unlimited
Returns:
the contents of the byte array as a hex-formatted string

format

public static String format(ByteBuffer buf)
Returns a string constructed with the contents of the ByteBuffer converted to hex format. The entire string is enclosed in square brackets, and the octets are separated by a single space character.

Parameters:
buf - a buffer to format
Returns:
the contents of the buffer as a hex-formatted string

format

public static String format(ByteBuffer buf,
                            int limit)
Returns a string constructed with the contents of the ByteBuffer converted to hex format. The entire string is enclosed in square brackets, and the octets are separated by a single space character.

Parameters:
buf - a buffer to format
limit - the maximum number of bytes to format, or 0 meaning unlimited
Returns:
the contents of the buffer as a hex-formatted string

toHexString

public static String toHexString(byte[] bytes)
Returns a string constructed with the contents of the byte array converted to hex format.

Parameters:
bytes - a byte array to convert
Returns:
the converted byte array as a hex-formatted string

toHexString

public static String toHexString(BigInteger bigInt)
Returns the specified bigInt as a hex-formatted string.

Parameters:
bigInt - a big integer to format
Returns:
the specified bigInt as a hex-formatted string

fromHexString

public static byte[] fromHexString(String hexString)
Returns a byte array constructed with the contents of the given string, which contains a series of byte values in hex format.

Parameters:
hexString - a string to convert
Returns:
the byte array corresponding to the hex-formatted string
Throws:
NumberFormatException - if the String does not contain a parsable series of hex-formatted values int


Copyright © 2007-2013. All Rights Reserved.