Here you can find the source of lastIndexOf(byte[] bytes, int pos, int len, byte b)
Parameter | Description |
---|---|
bytes | the array of bytes |
pos | the starting position within the array |
len | the number of bytes to search |
b | the byte the byte to find |
public static int lastIndexOf(byte[] bytes, int pos, int len, byte b)
//package com.java2s; /*/*from www . ja v a2s . c o m*/ * Copyright SparseWare Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * Returns the index of the last occurrence of the specified byte in the specified * array. * * @param bytes the array of bytes * @param pos the starting position within the array * @param len the number of bytes to search * @param b the byte the byte to find * * @return the index of the last occurrence of the specified byte; returns -1 if the * object is not found. */ public static int lastIndexOf(byte[] bytes, int pos, int len, byte b) { for (int i = len - 1; i >= pos; i--) { if (bytes[i] == b) { return i; } } return -1; } }