Java Array Starts With startsWithGaps(final byte[] aFrag, final int numStartGaps)

Here you can find the source of startsWithGaps(final byte[] aFrag, final int numStartGaps)

Description

starts With Gaps

License

Apache License

Declaration

public static boolean startsWithGaps(final byte[] aFrag, final int numStartGaps) 

Method Source Code

//package com.java2s;
/*//  w ww  .  j av a 2 s. c o  m
 * Copyright (c) 2007-2013  David Soergel  <dev@davidsoergel.com>
 * Licensed under the Apache License, Version 2.0
 * http://www.apache.org/licenses/LICENSE-2.0
 */

public class Main {
    public static boolean startsWithGaps(final byte[] aFrag, final int numStartGaps) {
        for (int i = 0; i < numStartGaps; i++) {
            // if the fragment is shorter than the window but contains only gaps, return true
            if (i >= aFrag.length) {
                return true;
            }
            if (!isGap(aFrag[i])) {
                return false;
            }
        }
        return true;
    }

    public static boolean isGap(byte x)//, String gapChars)
    {
        return x == '-' || x == '.' || x == ' ';
        //   return gapChars.indexOf((char) x) != -1;
    }
}

Related

  1. startsWith(char[] prefix, char[] other)
  2. startsWith(char[] src, char[] find, int startAt)
  3. startsWith(char[] str1, String str2)
  4. startsWith(final byte[] array, final byte[] prefix)
  5. startsWith(final byte[] str, int startIndex, int endIndex, final byte ch)
  6. startsWithZipMagicBytes(byte[] data)