com.acap.rudp.core
Class ByteUtil

java.lang.Object
  extended by com.acap.rudp.core.ByteUtil

public class ByteUtil
extends java.lang.Object


Constructor Summary
ByteUtil()
           
 
Method Summary
static byte[] flipByteArray(byte[] oldArray)
           
static byte[] get2Bytes(int i)
           
static byte[] get4Bytes(int i)
           
static byte[] get4BytesInv(int i)
           
static byte[] get8Bytes(long i)
           
static byte[] toBytesBigEndian(long val)
           
static int toInt(byte[] in)
           
static int toInt(byte[] in, int ofs)
           
static int toInt(byte in0, byte in1, byte in2, byte in3)
           
static long toLong(byte[] bytes)
          Converts a byte array to a long value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteUtil

public ByteUtil()
Method Detail

get2Bytes

public static final byte[] get2Bytes(int i)

get4Bytes

public static final byte[] get4Bytes(int i)

get4BytesInv

public static final byte[] get4BytesInv(int i)

get8Bytes

public static final byte[] get8Bytes(long i)

toInt

public static final int toInt(byte in0,
                              byte in1,
                              byte in2,
                              byte in3)

toInt

public static final int toInt(byte[] in)

toInt

public static final int toInt(byte[] in,
                              int ofs)

toBytesBigEndian

public static byte[] toBytesBigEndian(long val)

toLong

public static long toLong(byte[] bytes)
Converts a byte array to a long value.

Parameters:
bytes - array of bytes
offset - offset into array
length - length of data (must be #SIZEOF_LONG)
Returns:
the long value
Throws:
java.lang.IllegalArgumentException - if length is not #SIZEOF_LONG or if there's not enough room in the array at the offset indicated.

flipByteArray

public static final byte[] flipByteArray(byte[] oldArray)