Here you can find the source of getCRLFIndex(ByteBuffer buffer)
public static int getCRLFIndex(ByteBuffer buffer)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static int getCRLFIndex(ByteBuffer buffer) { int len = buffer.position(); int s = 0; for (int i = 0; i < len; i++) { switch (buffer.get(i)) { case '\r': s = 1;/*from ww w . j a v a 2 s. c o m*/ break; case '\n': if (s == 1) return i - 1; break; default: s = 0; break; } } return -1; } }