|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.mindtree.techworks.insight.remoteprotocol.util.ByteUtils
public class ByteUtils
Util class for byte manipulation.
| Constructor Summary | |
|---|---|
ByteUtils()
|
|
| Method Summary | |
|---|---|
static byte[] |
getByteArrayForCharacterArray(char[] inputArray)
Creates a byte array representing the input character array. |
static byte[] |
getByteArrayForInt(int valueToConvert)
Creates a byte array for an int. |
static byte[] |
getByteArrayForShort(short valueToConvert)
Creates a byte array for a short. |
static byte[] |
getByteArrayForString(java.lang.String inputString)
Creates a byte array representing the Input String. |
static void |
putBytesInArrayForInt(int valueToConvert,
byte[] buf,
int offset)
Creates a byte array for an int. |
static void |
putBytesInArrayForShort(short valueToConvert,
byte[] buf,
int offset)
Creates a byte array for a short. |
static int |
readIntFromByteArray(byte[] inputArr,
int offset)
Reads an int value from a byte array. |
static short |
readShortFromByteArray(byte[] inputArr,
int offset)
Reads a short value from a byte array. |
static java.lang.String |
readStringFromByteArray(byte[] inputArr,
int offset,
int length)
Decodes a string value from the byte Array passed in. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ByteUtils()
| Method Detail |
|---|
public static short readShortFromByteArray(byte[] inputArr,
int offset)
short value from a byte array.
inputArr - The byte array to read data fromoffset - The offset to read data from
java.lang.ArrayIndexOutOfBoundsException - If data cannot be read from specified position
public static int readIntFromByteArray(byte[] inputArr,
int offset)
int value from a byte array.
inputArr - The byte array to read data fromoffset - The offset to read data from
java.lang.ArrayIndexOutOfBoundsException - If data cannot be read from specified positionpublic static byte[] getByteArrayForShort(short valueToConvert)
short. The returned array
always has 2 elements.
valueToConvert - The short value to convert
public static void putBytesInArrayForShort(short valueToConvert,
byte[] buf,
int offset)
short. The array values are
placed in the input array buf from the position specified
by the offset.
valueToConvert - The short value to convertbuf - The buffer to place the bytes inoffset - The offset to insert the values from
java.lang.ArrayIndexOutOfBoundsException - If the specified position in the array is not available.public static byte[] getByteArrayForInt(int valueToConvert)
int. The returned array
always has 4 elements.
valueToConvert - The integer value to convert
public static void putBytesInArrayForInt(int valueToConvert,
byte[] buf,
int offset)
int. The array values are
placed in the input array buf from the position specified
by the offset.
valueToConvert - The integer value to convertbuf - The buffer to place the bytes inoffset - The offset to insert the values from
java.lang.ArrayIndexOutOfBoundsException - If the specified position in the array is not available.
public static byte[] getByteArrayForString(java.lang.String inputString)
throws java.nio.charset.CharacterCodingException
#getByteArrayForCharacterArray(char[])
method with the character array representing the string.
inputString - The input string to convert
java.nio.charset.CharacterCodingException - If there is an exception encoding the characters.
public static byte[] getByteArrayForCharacterArray(char[] inputArray)
throws java.nio.charset.CharacterCodingException
inputArray - The array to convert
java.nio.charset.CharacterCodingException - If there is an exception encoding the characters.
public static java.lang.String readStringFromByteArray(byte[] inputArr,
int offset,
int length)
throws java.nio.charset.CharacterCodingException
inputArr - The input arrayoffset - The position to start reading fromlength - The length to read upto
java.nio.charset.CharacterCodingException - If there is an exception decoding the characters.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||