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