Java Utililty Methods Array Starts With

List of utility methods to do Array Starts With

Description

The list of methods to do Array Starts With are organized into topic(s).

Method

booleanstartsWith(char[] str1, String str2)
Returns true if a prefix of the character array is the same as contents of a string.
int len = str2.length();
if (str1.length < len)
    return false;
for (int i = 0; i < len; i++) {
    if (str1[i] != str2.charAt(i)) {
        return false;
return true;
booleanstartsWith(final byte[] array, final byte[] prefix)
starts With
if (array == null)
    return false;
if (prefix == null)
    return false;
if (prefix.length > array.length)
    return false;
for (int i = 0; i < prefix.length; i++)
    if (array[i] != prefix[i])
...
booleanstartsWith(final byte[] str, int startIndex, int endIndex, final byte ch)
starts With
if (startIndex < 0) {
    startIndex = 0;
if (endIndex > str.length) {
    endIndex = str.length;
return (startIndex < endIndex) && (str[startIndex] == ch);
booleanstartsWithGaps(final byte[] aFrag, final int numStartGaps)
starts With Gaps
for (int i = 0; i < numStartGaps; i++) {
    if (i >= aFrag.length) {
        return true;
    if (!isGap(aFrag[i])) {
        return false;
return true;
booleanstartsWithZipMagicBytes(byte[] data)
Returns whether the given bytes start with the magic bytes that mark a ZIP file.
return isPrefix(new byte[] { 0x50, 0x4b, 0x03, 0x04 }, data);