Here you can find the source of skipChars(ByteBuffer buffer, byte[] chars)
public static void skipChars(ByteBuffer buffer, byte[] chars)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static void skipChars(ByteBuffer buffer, byte[] chars) { while (buffer.hasRemaining()) { byte b = buffer.get(); if (contains(chars, b)) { continue; } else { buffer.position(buffer.position() - 1); break; }/*from www. j a va 2 s. c o m*/ } } public static boolean contains(ByteBuffer buffer, byte b) { return contains(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining(), b); } public static boolean contains(byte[] data, byte b) { return contains(data, 0, data.length, b); } public static boolean contains(byte[] data, int offset, int length, byte b) { return indexOf(data, offset, length, b) >= 0; } public static int indexOf(ByteBuffer buffer, byte b) { return indexOf(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining(), b); } public static int indexOf(byte[] data, byte b) { return indexOf(data, 0, data.length, b); } public static int indexOf(byte[] data, int offset, int length, byte b) { int idx = -1; for (int i = offset; i < offset + length; i++) { if (data[i] == b) { idx = i; break; } } return idx; } }