org.littleshoot.util
Class BitUtils

java.lang.Object
  extended by org.littleshoot.util.BitUtils

public class BitUtils
extends Object

Utility methods for bit twiddling.


Constructor Summary
BitUtils()
           
 
Method Summary
static int byteArrayToInteger(byte[] b)
           
static int byteArrayToInteger(byte[] b, int offset)
           
static long byteArrayToLong(byte[] b)
           
static long byteArrayToLong(byte[] b, int offset)
           
static byte[] toByteArray(int i)
          Returns the bytes (big-endian) of an integer.
static byte[] toByteArray(long l)
          Converts the specified long to an array of bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitUtils

public BitUtils()
Method Detail

toByteArray

public static byte[] toByteArray(int i)
Returns the bytes (big-endian) of an integer.

Parameters:
i - The integer.
Returns:
A 4-byte array of the bytes of the integer.

toByteArray

public static byte[] toByteArray(long l)
Converts the specified long to an array of bytes.

Parameters:
l - The long to convert.
Returns:
The array of bytes with the most significant byte first.

byteArrayToInteger

public static int byteArrayToInteger(byte[] b)

byteArrayToInteger

public static int byteArrayToInteger(byte[] b,
                                     int offset)

byteArrayToLong

public static long byteArrayToLong(byte[] b)

byteArrayToLong

public static long byteArrayToLong(byte[] b,
                                   int offset)


Copyright © 2011-2013 LittleShoot. All Rights Reserved.