Return last position of symbol in byte array - Java java.lang

Java examples for java.lang:byte Array

Description

Return last position of symbol in byte array

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        byte[] btBuff = new byte[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };
        int iOffset = 2;
        System.out.println(lastIndexOfSequenceLetter(btBuff, iOffset));
    }//from  ww w . j  a v a 2s  . c o m

    /**
     * Return last position of symbol in byte array
     * @param btBuff buffer to search
     * @param iOffset start offset
     * @return first position of symbol in buffer, -1 if not found
     * @author Thai Hoang Hiep
     */
    ////////////////////////////////////////////////////////
    public static int lastIndexOfSequenceLetter(byte[] btBuff, int iOffset) {
        while (iOffset < btBuff.length && btBuff[iOffset] > 32)
            iOffset++;
        if (iOffset >= btBuff.length)
            return -1;
        return iOffset;
    }
}

Related Tutorials