com.generationjava.lang
Class ByteArray

java.lang.Object
  extended bycom.generationjava.lang.ByteArray

public class ByteArray
extends Object

Provides useful methods for manipulating ByteArrays. Todo: Integrate faster byte handling supplied by sclayman.

Author:
bayard@generationjava.com

Constructor Summary
ByteArray(byte[] b)
          Construct an object to contain an array of bytes.
 
Method Summary
static String byteArrayToString(byte[] b)
          converts a byte array into a String in hexidecimal form.
static String byteToString(byte b)
          given a byte, return a String like: "09" or "AA" etc..
static byte[] longArrayToByteArray(long[] lns)
          Flattern an array of longs into an array of byte.
static byte stringToByte(String s)
          given a String like: "09" or "AA" etc, return the relevant byte.
static byte[] stringToByteArray(String bstr)
          converts a hexidecimal form of String to a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteArray

public ByteArray(byte[] b)
Construct an object to contain an array of bytes.

Parameters:
b - byte[] of values to contain
Method Detail

byteArrayToString

public static String byteArrayToString(byte[] b)
converts a byte array into a String in hexidecimal form.

Parameters:
b - byte[] to turn to a String
Returns:
String of bytes in hexadecimal format

byteToString

public static String byteToString(byte b)
given a byte, return a String like: "09" or "AA" etc..

Parameters:
b - byte to turn to a String
Returns:
String of byte in hexadecimal format

stringToByte

public static byte stringToByte(String s)
given a String like: "09" or "AA" etc, return the relevant byte.

Parameters:
s - String of byte in hexadecimal format
Returns:
byte value of hexadecimal-string

stringToByteArray

public static byte[] stringToByteArray(String bstr)
converts a hexidecimal form of String to a byte array.

Parameters:
bstr - String of bytes in hexadecimal format
Returns:
byte[] values of hexadecimal-string

longArrayToByteArray

public static byte[] longArrayToByteArray(long[] lns)
Flattern an array of longs into an array of byte. The primitive type, 'long' is 8 times the size of a byte.

Parameters:
lns - Array of longs to be converted to bytes.
Returns:
byte value of hexadecimal-string


Copyright © 2000-2005 OSJava. All Rights Reserved.