skip substrings from an array of characters, where each character is a set of 2 bytes. - Android File Input Output

Android examples for File Input Output:Byte Array

Description

skip substrings from an array of characters, where each character is a set of 2 bytes.

Demo Code

/**// www.  jav  a  2s . co  m
 *******************************************************************************
 * Copyright (C) 1996-2004, International Business Machines Corporation and    *
 * others. All Rights Reserved.                                                *
 *******************************************************************************
 */
//package com.java2s;

public class Main {
    /**
     * skip substrings from an array of characters, where each character is a set 
     * of 2 bytes. substring is a set of non-zero bytes starting from argument 
     * start to the byte of the argument value. skips up to a max number of 
     * characters
     * @param array byte array to parse
     * @param index to start substrings in byte count
     * @param length the max number of bytes to skip
     * @param skipend value of byte to skip to
     * @return the number of bytes skipped
     */
    static int skipByteSubString(byte[] array, int index, int length,
            byte skipend) {
        int result;
        byte b;

        for (result = 0; result < length; result++) {
            b = array[index + result];
            if (b == skipend) {
                result++;
                break;
            }
        }

        return result;
    }
}

Related Tutorials