public class ByteArray
extends java.lang.Object
Constructor and Description |
---|
ByteArray(byte[] bArray)
The constructor
|
Modifier and Type | Method and Description |
---|---|
byte |
byteAt(int index)
Returns the byte value at the specified index.
|
char |
charAt(int index)
Returns the character value at the specified index.
|
byte[] |
concat(byte[] suffixArray)
Concatenates the specified byte array to the end of this byte array.
|
int |
convertToInt_BE()
Convert an integer to Big Endian format.
|
boolean |
endsWith(byte[] suffixArray)
Tests if this byte array ends with the specified suffix.
|
boolean |
equals(java.lang.Object other)
Value equality for byte arrays.
|
boolean |
equals(java.lang.Object other,
int offset)
Value equality for byte arrays.
|
byte[] |
getBytes()
Return the entire byte array
|
byte[] |
getBytes(int beginIndex)
Returns a byte array that is a sub byte array of this byte array.
|
byte[] |
getBytes(int beginIndex,
int endIndex)
Returns a byte array that is a sub byte array of this byte array.
|
int |
getLength()
Returns the length of the byte array.
|
int |
indexOf(byte searchFor)
Returns the index within this byte array of the first occurrence of the
specified byte.
|
int |
indexOf(byte[] searchFor)
Returns the index within this larger byte array of the first occurrence of
the specified byte array.
|
int |
indexOf(byte[] searchFor,
int fromIndex)
Returns the index within this larger byte array of the first occurrence of
the specified byte array, starting the search at a specified index.
|
int |
indexOf(byte searchFor,
int fromIndex)
Returns the index within this byte array of the first occurrence of the
specified byte, starting the search at a specified index.
|
int |
indexOf(char searchFor)
Returns the index within this byte array of the first occurrence of the
specified character.
|
int |
indexOf(char searchFor,
int fromIndex)
Returns the index within this byte array of the first occurrence of the
specified character, starting the search at a specified index.
|
int |
indexOf(java.lang.String searchFor)
Returns the index within this larger byte array of the first occurrence of
the specified string.
|
int |
indexOf(java.lang.String searchFor,
int fromIndex)
Returns the index within this byte array of the first occurrence of the
specified string, starting the search at a specified index.
|
boolean |
isEmpty()
Returns true, if and only if, length is zero.
|
int |
lastIndexOf(byte searchFor)
Returns the index within this byte array of the last occurrence of the
specified byte.
|
int |
lastIndexOf(byte[] searchFor)
Returns the index within this larger byte array of the last occurrence of
the specified byte array.
|
int |
lastIndexOf(byte[] searchFor,
int fromIndex)
Returns the index within this larger byte array of the last occurrence of
the specified byte array, starting the search at a specified index.
|
int |
lastIndexOf(byte searchFor,
int fromIndex)
Returns the index within this byte array of the last occurrence of the
specified byte, starting the search at a specified index.
|
int |
lastIndexOf(char searchFor)
Returns the index within this byte array of the last occurrence of the
specified character.
|
int |
lastIndexOf(char searchFor,
int fromIndex)
Returns the index within this byte array of the last occurrence of the
specified character, starting the search at a specified index.
|
int |
lastIndexOf(java.lang.String searchFor)
Returns the index within this larger byte array of the last occurrence of
the specified string.
|
int |
lastIndexOf(java.lang.String searchFor,
int fromIndex)
Returns the index within this byte array of the last occurrence of the
specified string, starting the search at a specified index.
|
int |
length()
Returns the length of the byte array.
|
byte[] |
replace(byte[] oldByteArray,
byte[] newByteArray)
Replace all occurrences of oldByteArray in this byte array with newByteArray.
|
byte[] |
replace(byte oldByte,
byte newByte)
Replace all occurrences of oldByte in this byte array with newByte.
|
byte[] |
replace(char oldChar,
char newChar)
Replace all occurrences of oldChar in this byte array with newChar.
|
void |
replaceAndResize(byte[] oldByteArray,
byte[] newByteArray)
Replace all occurrences of oldByteArray in this byte array with newByteArray.
|
byte[] |
resize(int newSize)
Resize the byte array to a new size.
|
byte[][] |
split(byte delimiter)
Return an array of byte arrays.
|
byte[][] |
split(char delimiter)
Return an array of byte arrays.
|
boolean |
startsWith(byte[] prefix)
Tests if this byte array starts with the specified prefix.
|
boolean |
startsWith(byte[] prefix,
int offset)
Tests if the sub byte array of this byte array beginning at the
specified index starts with the specified prefix.
|
byte[] |
toByteArray()
Return the entire byte array
|
char[] |
toCharArray()
Return the byte array as a character array
|
java.lang.String |
toHexArray()
Return the byte array as a hexadecimal representation.
|
java.lang.String |
toString()
Return byte array as a string.
|
public ByteArray(byte[] bArray)
bArray
- use the byte array passed in.public byte byteAt(int index)
index
- within the byte array to select the byte.public char charAt(int index)
index
- within the byte array to select the byte.public byte[] concat(byte[] suffixArray)
suffixArray
- inputed byte array for concatenation.public int convertToInt_BE()
public boolean endsWith(byte[] suffixArray)
suffixArray
- inputed byte arraypublic boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- object to be compared againstpublic boolean equals(java.lang.Object other, int offset)
other
- object to be compared againstoffset
- offset to start the comparison at.public byte[] getBytes()
public byte[] getBytes(int beginIndex) throws java.lang.IndexOutOfBoundsException
beginIndex
- starting index for the selectionjava.lang.IndexOutOfBoundsException
public byte[] getBytes(int beginIndex, int endIndex) throws java.lang.IndexOutOfBoundsException
beginIndex
- starting index for the selectionendIndex
- ending index for the selectionjava.lang.IndexOutOfBoundsException
public int getLength()
public int indexOf(byte[] searchFor)
searchFor
- value to be searched forpublic int indexOf(byte[] searchFor, int fromIndex)
searchFor
- value to be searched forfromIndex
- starting positionpublic int indexOf(byte searchFor)
searchFor
- value to be searched forpublic int indexOf(byte searchFor, int fromIndex)
searchFor
- value to be searched forfromIndex
- starting positionpublic int indexOf(java.lang.String searchFor)
searchFor
- value to be searched forpublic int indexOf(java.lang.String searchFor, int fromIndex)
searchFor
- value to be searched forfromIndex
- starting positionpublic int indexOf(char searchFor)
searchFor
- value to be searched forpublic int indexOf(char searchFor, int fromIndex)
searchFor
- value to be searched forfromIndex
- starting positionpublic boolean isEmpty()
public int lastIndexOf(byte[] searchFor)
searchFor
- value to be searched forpublic int lastIndexOf(byte[] searchFor, int fromIndex)
searchFor
- value to be searched forfromIndex
- starting positionpublic int lastIndexOf(byte searchFor)
searchFor
- value to be searched forpublic int lastIndexOf(byte searchFor, int fromIndex)
searchFor
- value to be searched forfromIndex
- starting positionpublic int lastIndexOf(java.lang.String searchFor)
searchFor
- value to be searched forpublic int lastIndexOf(java.lang.String searchFor, int fromIndex)
searchFor
- value to be searched forfromIndex
- starting positionpublic int lastIndexOf(char searchFor)
searchFor
- value to be searched forpublic int lastIndexOf(char searchFor, int fromIndex)
searchFor
- value to be searched forfromIndex
- starting positionpublic int length()
public byte[] replace(char oldChar, char newChar)
oldChar
- original character to search for and be replacednewChar
- replacement characterpublic byte[] replace(byte oldByte, byte newByte)
oldByte
- original byte to search for and be replacednewByte
- replacement bytepublic byte[] replace(byte[] oldByteArray, byte[] newByteArray) throws java.lang.IndexOutOfBoundsException
oldByteArray
- original byte array to search for and be replacednewByteArray
- replacement byte arrayjava.lang.IndexOutOfBoundsException
public void replaceAndResize(byte[] oldByteArray, byte[] newByteArray) throws java.lang.IndexOutOfBoundsException
oldByteArray
- original byte array to search for and be replacednewByteArray
- replacement byte arrayjava.lang.IndexOutOfBoundsException
public byte[] resize(int newSize)
newSize
- the value for the new size of the byte array.public byte[][] split(char delimiter)
delimiter
- the character delimiter to be used as to split the byte array.public byte[][] split(byte delimiter)
delimiter
- the byte delimiter to be used as to split the byte array.public boolean startsWith(byte[] prefix)
prefix
- inputed byte arraypublic boolean startsWith(byte[] prefix, int offset)
prefix
- inputed byte arrayoffset
- offset within byte array to start the comparison at.public byte[] toByteArray()
public char[] toCharArray()
public java.lang.String toHexArray()
public java.lang.String toString()
toString
in class java.lang.Object