org.openbp.common.util
Class ByteArrayUtil

java.lang.Object
  extended by org.openbp.common.util.ByteArrayUtil

public final class ByteArrayUtil
extends java.lang.Object

Byte array manipulation methods.

Author:
Heiko Erhardt, Dr. Achim Leubner

Method Summary
static byte fromHex(java.lang.String hex)
           
static byte[] fromShortHexString(java.lang.String hex)
           
static byte[] replaceBytes(byte[] bytes, byte[] pattern, byte[] replacement)
           
static byte[] toBytes(long lp)
          Returns the byte array representation of the long.
static java.lang.String toGroupedShortHexString(byte[] b)
          Same as toShortHexString(), but after each 8 bytes, a space is inserted.
static java.lang.String toHexString(byte b)
          Returns a hexadecimal representation of the byte.
static java.lang.String toHexString(byte[] b)
          Returns a hexadecimal representation of the byte array.
static java.lang.String toShortHexString(byte[] b)
          Returns a short hexadecimal representation of the byte array.
static java.lang.String toString(byte[] b)
          Returns a String representation of the byte array formatted as in "[F1, 01, 10]".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

replaceBytes

public static byte[] replaceBytes(byte[] bytes,
                                  byte[] pattern,
                                  byte[] replacement)

toHexString

public static java.lang.String toHexString(byte b)
Returns a hexadecimal representation of the byte.

Parameters:
b - Byte
Returns:
The string representation

toHexString

public static java.lang.String toHexString(byte[] b)
Returns a hexadecimal representation of the byte array.

Parameters:
b - Byte array
Returns:
The string representation

toString

public static java.lang.String toString(byte[] b)
Returns a String representation of the byte array formatted as in "[F1, 01, 10]".

Parameters:
b - Byte array
Returns:
The string representation

toShortHexString

public static java.lang.String toShortHexString(byte[] b)
Returns a short hexadecimal representation of the byte array.


fromShortHexString

public static byte[] fromShortHexString(java.lang.String hex)
                                 throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

fromHex

public static byte fromHex(java.lang.String hex)
                    throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

toGroupedShortHexString

public static java.lang.String toGroupedShortHexString(byte[] b)
Same as toShortHexString(), but after each 8 bytes, a space is inserted.


toBytes

public static byte[] toBytes(long lp)
Returns the byte array representation of the long.



Copyright © 2011. All Rights Reserved.