Package de.intarsys.tools.collection
Class ByteArrayTools
java.lang.Object
de.intarsys.tools.collection.ByteArrayTools
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]concat(byte[] array1, byte[] array2) static byte[]copy(byte[] bytes) Make a copy ofbytes.static byte[]copy(byte[] bytes, int offset, int length) Copylengthbytes frombytesstarting atfrom.static intindexOf(byte[] source, int sourceOffset, int sourceLen, byte[] pattern, int patternOffset, int patternLen, int fromIndex) Search index of pattern in source.static booleanstartsWith(byte[] bytes, byte[] pattern) trueifbytesstarts with the byte sequence defined inpattern.
-
Constructor Details
-
ByteArrayTools
public ByteArrayTools()
-
-
Method Details
-
concat
public static byte[] concat(byte[] array1, byte[] array2) -
copy
public static byte[] copy(byte[] bytes) Make a copy ofbytes.- Parameters:
bytes- byte[] to be copied- Returns:
- A copy of
bytes
-
copy
public static byte[] copy(byte[] bytes, int offset, int length) Copylengthbytes frombytesstarting atfrom.- Parameters:
bytes- byte[] to be copiedoffset- starting position to copy fromlength- number of bytes- Returns:
- A copy of
bytes
-
indexOf
public static int indexOf(byte[] source, int sourceOffset, int sourceLen, byte[] pattern, int patternOffset, int patternLen, int fromIndex) Search index of pattern in source. Algorithm from java.lang.String- Parameters:
source-sourceOffset-sourceLen-pattern-patternOffset-patternLen-fromIndex-- Returns:
- The index of the first occurrence of pattern or -1.
-
startsWith
public static boolean startsWith(byte[] bytes, byte[] pattern) trueifbytesstarts with the byte sequence defined inpattern.- Parameters:
bytes-pattern-- Returns:
trueifbytesstarts with the byte sequence defined inpattern.
-