Package edu.indiana.lib.twinpeaks.util
Class ByteUtils
- java.lang.Object
-
- edu.indiana.lib.twinpeaks.util.ByteUtils
-
public class ByteUtils extends Object
Byte utilities
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanequals(byte[] source, byte[] match)Does the source array equal the match array?static voidgetBytes(byte[] source, int srcBegin, int srcEnd, byte[] destination, int dstBegin)Copies bytes from the source byte array to the destination arraystatic intindexOf(byte[] source, byte[] match)Returns the index in the source array where the first occurrence of the specified byte pattern is foundstatic intindexOf(byte[] source, String matchString)Returns the index in the source array where the first occurrence of the specified text (a String, converted to a byte array) is foundstatic intlastIndexOf(byte[] source, byte[] match)Returns the index in the source array where the last occurrence of the specified byte pattern is foundstatic intlastIndexOf(byte[] source, String matchString)Returns the index in the source array where the last occurrence of the specified text (a String, converted to a byte array) is foundstatic voidmain(String[] args)static booleanstartsWith(byte[] source, byte[] match)Does this byte array begin with match array content?static booleanstartsWith(byte[] source, int offset, byte[] match)Does this byte array begin with match array content?static byte[]subbytes(byte[] source, int srcBegin)Return a new byte array containing a sub-portion of the source arraystatic byte[]subbytes(byte[] source, int srcBegin, int srcEnd)Return a new byte array containing a sub-portion of the source array
-
-
-
Method Detail
-
indexOf
public static int indexOf(byte[] source, String matchString)Returns the index in the source array where the first occurrence of the specified text (a String, converted to a byte array) is found- Parameters:
source- Byte array to examinematchString- String to locate insource- Returns:
- Index of the first matching character (-1 if no match)
-
indexOf
public static int indexOf(byte[] source, byte[] match)Returns the index in the source array where the first occurrence of the specified byte pattern is found- Parameters:
source- Byte array to examinematch- Byte array to locate insource- Returns:
- Index of the first matching character (-1 if no match)
-
lastIndexOf
public static int lastIndexOf(byte[] source, String matchString)Returns the index in the source array where the last occurrence of the specified text (a String, converted to a byte array) is found- Parameters:
source- Byte array to examinematchString- String to locate insource- Returns:
- Index of the first matching character (-1 if no match)
-
lastIndexOf
public static int lastIndexOf(byte[] source, byte[] match)Returns the index in the source array where the last occurrence of the specified byte pattern is found- Parameters:
source- Byte array to examinematch- Byte array to locate insource- Returns:
- Index of the last matching character (-1 if no match)
-
startsWith
public static boolean startsWith(byte[] source, byte[] match)Does this byte array begin with match array content?- Parameters:
source- Byte array to examinematch- Byte array to locate insource- Returns:
- true If the starting bytes are equal
-
startsWith
public static boolean startsWith(byte[] source, int offset, byte[] match)Does this byte array begin with match array content?- Parameters:
source- Byte array to examineoffset- An offset into thesourcearraymatch- Byte array to locate insource- Returns:
- true If the starting bytes are equal
-
equals
public static boolean equals(byte[] source, byte[] match)Does the source array equal the match array?- Parameters:
source- Byte array to examineoffset- An offset into thesourcearraymatch- Byte array to locate insource- Returns:
- true If the two arrays are equal
-
getBytes
public static void getBytes(byte[] source, int srcBegin, int srcEnd, byte[] destination, int dstBegin)Copies bytes from the source byte array to the destination array- Parameters:
source- The source arraysrcBegin- Index of the first source byte to copysrcEnd- Index after the last source byte to copydestination- The destination arraydstBegin- The starting offset in the destination array
-
subbytes
public static byte[] subbytes(byte[] source, int srcBegin, int srcEnd)Return a new byte array containing a sub-portion of the source array- Parameters:
srcBegin- The beginning index (inclusive)srcEnd- The ending index (exclusive)- Returns:
- The new, populated byte array
-
subbytes
public static byte[] subbytes(byte[] source, int srcBegin)Return a new byte array containing a sub-portion of the source array- Parameters:
srcBegin- The beginning index (inclusive)- Returns:
- The new, populated byte array
-
-