Java ByteBuffer Put readPackedLong(ByteBuffer input)

Here you can find the source of readPackedLong(ByteBuffer input)

Description

read Packed Long

License

Open Source License

Declaration

public static long readPackedLong(ByteBuffer input) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.nio.ByteBuffer;

public class Main {
    public static long readPackedLong(ByteBuffer input) {
        long result = 0;
        long read;
        long index = 0;
        do {//from w  w  w.  j  a va 2  s.  c o  m
            read = input.get() & 0xFF;
            result += (read & 127) << index;
            index += 7;
        } while (read > 127);
        assert result >= 0;
        return result;
    }
}

Related

  1. readFully(InputStream in, ByteBuffer out)
  2. readFully(InputStream is, ByteBuffer buf)
  3. readFully(InputStream is, ByteBuffer buffer, int nrBytes)
  4. readInto(ByteBuffer buf, InputStream inputStream)
  5. readNextLine(InputStream in, ByteBuffer buff, boolean acceptEOF, boolean requireCR)
  6. readToByteBuffer(InputStream inStream)
  7. serializeNullableString(ByteBuffer outputBuffer, String value)
  8. serializeObject(Object obj, ByteBuffer buffer, ByteArrayOutputStream baos, boolean markEndOfHeader)
  9. setBit(ByteBuffer input, int pos)