public static int lineEnd(ByteBuffer buffer, int maxLength) {
		int primitivePosition = buffer.position();
		boolean canEnd = false;
		int charIndex = primitivePosition;
		byte b;
		while (buffer.hasRemaining()) {
			b = buffer.get();
			charIndex++;
			if (b == StrUtil.C_CR) {
				canEnd = true;
			} else if (b == StrUtil.C_LF) {
				return canEnd ? charIndex - 2 : charIndex - 1;
			} else {
				// 只有\r无法确认换行
				canEnd = false;
			}

			if (charIndex - primitivePosition > maxLength) {
				// 查找到尽头，未找到，还原位置
				buffer.position(primitivePosition);
				throw new IndexOutOfBoundsException(StrUtil.format("Position is out of maxLength: {}", maxLength));
			}
		}

		// 查找到buffer尽头，未找到，还原位置
		buffer.position(primitivePosition);
		// 读到结束位置
		return -1;
	}
public static int lineEnd ( ByteBuffer buffer , int maxLength ) { int primitivePosition = buffer . position ( ) ; boolean canEnd = false ; int charIndex = primitivePosition ; byte b ; while ( buffer . hasRemaining ( ) ) { b = buffer . get ( ) ; charIndex ++ ; if ( b == StrUtil . C_CR ) { canEnd = true ; } else if ( b == StrUtil . C_LF ) { return canEnd ? charIndex - 2 : charIndex - 1 ; } else { canEnd = false ; } if ( charIndex - primitivePosition > maxLength ) { buffer . position ( primitivePosition ) ; throw new IndexOutOfBoundsException ( StrUtil . format ( "Position is out of maxLength: {}" , maxLength ) ) ; } } buffer . position ( primitivePosition ) ; return - 1 ; }
一行的末尾位置，查找位置时位移ByteBuffer到结束位置<br>
支持的换行符如下：

<pre>
1. \r\n
2. \n
</pre>

@param buffer {@link ByteBuffer}
@param maxLength 读取最大长度
@return 末尾位置，未找到或达到最大长度返回-1