Java Array Contain arrayContainsOK(final byte[] b)

Here you can find the source of arrayContainsOK(final byte[] b)

Description

Checks for the combination looking from end to begining, in the whole array

License

Open Source License

Parameter

Parameter Description
b a parameter

Return

true if found, false otherwise

Declaration

public static boolean arrayContainsOK(final byte[] b) 

Method Source Code

//package com.java2s;
/**//from   w  w w .j  a v a2 s .  c  o m
 *    Created on Oct 21, 2010
 *    This file is part of JObexFTP 2.0, and it contains parts of OBEX4J.
 *
 *    JObexFTP is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU Lesser General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    JObexFTP is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public License
 *    along with JObexFTP.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

public class Main {
    /**
     * Checks for the combination looking from end to begining, in the whole array
     * @param b
     * @return true if found, false otherwise
     */
    public static boolean arrayContainsOK(final byte[] b) {
        for (int i = b.length - 1; i >= 3; i--) {
            if (b[i] == 13 && b[i - 1] == 75 && b[i - 2] == 79 && b[i - 3] == 10) {
                return true;
            }
        }
        return false;
    }
}

Related

  1. arrayContainsIgnoreCase(String[] array, String searchKey)
  2. arrayContainsIgnoreCase(String[] array, String str)
  3. arrayContainsInt(int[] array, int test)
  4. arrayContainsLower(String[] lemmas, String string)
  5. arrayContainsNumber(Number[] array, Number number)
  6. arrayContainsOnlyIgnoreCase(String[] array, String... strs)
  7. arrayContainsOverlap(Object[] array1, Object[] array2)
  8. arrayContainsPartKey(String[] array, String key)
  9. arrayContainsString(String[] arr, String str, boolean isCaseSensitive)