com.asdf.utils
Class ByteUtils

java.lang.Object
  extended by com.asdf.utils.ByteUtils

public class ByteUtils
extends java.lang.Object


Constructor Summary
ByteUtils()
           
 
Method Summary
static java.nio.ByteBuffer[] brokeToPieces(byte[] data, int chunkSize)
          Returns given data chopped to BYTE_CHUNK_SIZE sized ByteBuffer pieces.
static int bytesToInt(byte[] data)
          Converts byte array to java integer.
static byte[] intToBytes(int integer)
          Converts int to byte array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteUtils

public ByteUtils()
Method Detail

brokeToPieces

public static java.nio.ByteBuffer[] brokeToPieces(byte[] data,
                                                  int chunkSize)
Returns given data chopped to BYTE_CHUNK_SIZE sized ByteBuffer pieces. Data is prepended with the size of the data.

Parameters:
data - to chop
Returns:
Array of bytebuffers containing pieces

bytesToInt

public static int bytesToInt(byte[] data)
                      throws java.io.IOException
Converts byte array to java integer.

Parameters:
data - Byte array
Returns:
Integer
Throws:
java.io.IOException

intToBytes

public static byte[] intToBytes(int integer)
                         throws java.io.IOException
Converts int to byte array.

Parameters:
integer - Integer to convert
Returns:
Byte array containing given integer
Throws:
java.io.IOException