private static int getNewlineInByteArray(byte[] in, int o, int max){
        byte r = "\r".getBytes()[0];
        byte n = "\n".getBytes()[0];
        for(int i = o; i < Math.min(max, in.length) -1; i++){
            if(in[i] == r && in[i+1] == n){
                return i;
            }
        }
        return -1;
    }