cds.util
Class Bytes

java.lang.Object
  extended bycds.util.Bytes

public class Bytes
extends java.lang.Object

Utility methods for bytes array manipulation

Version:
1.0 Jun 2002
Author:
Marc Wenger/CDS

Field Summary
private static int LINESIZE
           
 
Constructor Summary
Bytes()
           
 
Method Summary
static char hexachar(int i)
          Convert a hexadecimal digit (0-15) into 0..9A..F
static java.lang.String hexadump(byte[] bytes)
          Displays in a String the heaxadecimal dump of the byte array The dump contains 20 bytes on line, grouped by 4 bytes, and displaying on the right the characters which can be printed.
static java.lang.String hexadump(byte[] bytes, int off, int len, int adjlen)
          Displays in one line all the bytes defined by the offset and length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LINESIZE

private static final int LINESIZE
See Also:
Constant Field Values
Constructor Detail

Bytes

public Bytes()
Method Detail

hexadump

public static java.lang.String hexadump(byte[] bytes)
Displays in a String the heaxadecimal dump of the byte array The dump contains 20 bytes on line, grouped by 4 bytes, and displaying on the right the characters which can be printed. The beginning of a line contains an address

Parameters:
bytes - the array of bytes to dump
Returns:
the string containing the dumped bytes

hexachar

public static char hexachar(int i)
Convert a hexadecimal digit (0-15) into 0..9A..F

Parameters:
i - hexadecimal digit
Returns:
a char in the range '0' .. '9' 'A' .. 'F'

hexadump

public static java.lang.String hexadump(byte[] bytes,
                                        int off,
                                        int len,
                                        int adjlen)
Displays in one line all the bytes defined by the offset and length. Adjust for a given number of bytes

Parameters:
bytes - byte array to convert into hexadecimal
off - offset in the array of the beginning of the conversion
len - number of bytes to convert
adjlen - justification of the fields as if there were that many bytes to display. If adjlen <= len, no justification occur
Returns:
the dumped line