Java ByteBuffer Get getCRLFIndex(ByteBuffer buffer)

Here you can find the source of getCRLFIndex(ByteBuffer buffer)

Description

get CRLF Index

License

Open Source License

Declaration

public static int getCRLFIndex(ByteBuffer buffer) 

Method Source Code

//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;
    }
}

Related

  1. getByteLen(ByteBuffer buffer)
  2. getChars(ByteBuffer buf, int off, int count)
  3. getCPCharacter(ByteBuffer buffer)
  4. getCrcChecksum(ByteBuffer buffer)
  5. getCRLFCRLFIndex(ByteBuffer buffer)
  6. getCRLFLine(ByteBuffer buf)
  7. getData(ByteBuffer buf, int index, int size)
  8. getDataFromBuffer(ByteBuffer b)
  9. getDirectByteBuffer(ByteBuffer var0, boolean var1)