anon.util
Class ByteArrayUtil

java.lang.Object
  extended by anon.util.ByteArrayUtil

public class ByteArrayUtil
extends java.lang.Object

Author:
stefan some usefull utilities

Constructor Summary
ByteArrayUtil()
           
 
Method Summary
static void byteArrayToCharArray(byte[] in, int inoff, char[] out, int outoff, int len)
          Copies len bytes starting from offin to out starting at outoff.
static void bzero(byte[] ar, int off, int len)
          Set len bytes starting form off to zero
static void bzero(char[] ar, int off, int len)
          Set len bytes starting form off to zero
static void charArrayToByteArray(char[] in, int inoff, byte[] out, int outoff, int len)
          Copies len bytes starting from offin to out starting at outoff.
static byte[] conc(byte[] b1, byte[] b2)
          Concatenates bytearrays
static byte[] conc(byte[] b1, byte[] b2, byte[] b3)
          Concatenates bytearrays
static byte[] conc(byte[] b1, byte[] b2, byte[] b3, byte[] b4)
          Concatenates bytearrays
static byte[] conc(byte[] b1, byte[] b2, byte[] b3, byte[] b4, byte[] b5)
          Concatenates bytearrays
static byte[] conc(byte[] b1, byte[] b2, byte[] b3, byte[] b4, byte[] b5, byte[] b6)
          Concatenates bytearrays
static byte[] conc(byte[] b1, byte[] b2, int b2_len)
          Concatenates two byte arrays
static byte[] copy(byte[] bytes, int index, int length)
          copy some bytes from an array of bytes
static boolean equal(byte[] arrayOne, byte[] arrayTwo)
          Tests if two byte arrays are equal.
static boolean equal(byte[] a_arrayA, int a_Aoff, byte[] a_arrayB, int a_Boff, int a_length)
          Tests if a_length positions of two arrays are equal.
static boolean equal(char[] a_arrayA, int a_Aoff, char[] a_arrayB, int a_Boff, int a_length)
          Tests if a_length positions of two arrays are equal.
static byte[] inttobyte(long l, int length)
          Converts a long to a array of bytes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteArrayUtil

public ByteArrayUtil()
Method Detail

conc

public static byte[] conc(byte[] b1,
                          byte[] b2)
Concatenates bytearrays

Returns:
concatenated array

conc

public static byte[] conc(byte[] b1,
                          byte[] b2,
                          byte[] b3)
Concatenates bytearrays

Returns:
concatenated array

conc

public static byte[] conc(byte[] b1,
                          byte[] b2,
                          byte[] b3,
                          byte[] b4)
Concatenates bytearrays

Returns:
concatenated array

conc

public static byte[] conc(byte[] b1,
                          byte[] b2,
                          byte[] b3,
                          byte[] b4,
                          byte[] b5)
Concatenates bytearrays

Returns:
concatenated array

conc

public static byte[] conc(byte[] b1,
                          byte[] b2,
                          byte[] b3,
                          byte[] b4,
                          byte[] b5,
                          byte[] b6)
Concatenates bytearrays

Returns:
concatenated array

conc

public static byte[] conc(byte[] b1,
                          byte[] b2,
                          int b2_len)
Concatenates two byte arrays

Parameters:
b1 -
b2 -
Returns:

inttobyte

public static byte[] inttobyte(long l,
                               int length)
Converts a long to a array of bytes

Parameters:
l -
length -
Returns:

copy

public static byte[] copy(byte[] bytes,
                          int index,
                          int length)
copy some bytes from an array of bytes

Parameters:
bytes - array of bytes
index - startposition
length - length
Returns:
copied bytes

equal

public static boolean equal(byte[] arrayOne,
                            byte[] arrayTwo)
Tests if two byte arrays are equal.

Parameters:
arrayOne - a byte array
arrayTwo - another byte array
Returns:
true if the two byte arrays are equal or both arrays are null; false otherwise

equal

public static final boolean equal(byte[] a_arrayA,
                                  int a_Aoff,
                                  byte[] a_arrayB,
                                  int a_Boff,
                                  int a_length)
Tests if a_length positions of two arrays are equal.

Parameters:
a_arrayA - byte[]
a_APos - int
a_arrayB - byte[]
a_BPos - int
a_length - int
Returns:
boolean

equal

public static final boolean equal(char[] a_arrayA,
                                  int a_Aoff,
                                  char[] a_arrayB,
                                  int a_Boff,
                                  int a_length)
Tests if a_length positions of two arrays are equal.

Parameters:
a_arrayA - char[]
a_APos - int
a_arrayB - char[]
a_BPos - int
a_length - int
Returns:
boolean

bzero

public static void bzero(byte[] ar,
                         int off,
                         int len)
Set len bytes starting form off to zero


bzero

public static void bzero(char[] ar,
                         int off,
                         int len)
Set len bytes starting form off to zero


byteArrayToCharArray

public static void byteArrayToCharArray(byte[] in,
                                        int inoff,
                                        char[] out,
                                        int outoff,
                                        int len)
Copies len bytes starting from offin to out starting at outoff. Two bytes are concatenated to form a single char


charArrayToByteArray

public static void charArrayToByteArray(char[] in,
                                        int inoff,
                                        byte[] out,
                                        int outoff,
                                        int len)
Copies len bytes starting from offin to out starting at outoff.