CharBuffer match Up To Char - Java java.nio

Java examples for java.nio:CharBuffer

Description

CharBuffer match Up To Char

Demo Code


//package com.java2s;
import java.nio.CharBuffer;

public class Main {
    public static int matchUpToChar(CharBuffer buf, int fromInc, int limit,
            char target) {
        for (int i = fromInc; i < limit; i++) {
            char c = buf.get(i);
            if (c == target) {
                return i;
            }//from   w w  w  .j av  a2  s  .  c  o m
        }

        return -1;
    }
}

Related Tutorials