Here you can find the source of readNewLine(ByteBuffer buf)
public static int readNewLine(ByteBuffer buf)
//package com.java2s; //License from project: LGPL import java.nio.ByteBuffer; public class Main { public static int readNewLine(ByteBuffer buf) { char ch;//from ww w . ja va2 s. co m int num = 0; while (buf.remaining() > 0) { ch = (char) buf.get(); num++; if (ch == '\n') break; } return num; } }