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

Java examples for java.lang:byte Array to String

Description

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

Demo Code

/**//ww  w.  jav  a  2 s .  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