Java DataInput Read Long readLong(DataInput in)

Here you can find the source of readLong(DataInput in)

Description

read Long

License

LGPL

Declaration

public static long readLong(DataInput in) throws Exception 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.io.*;

public class Main {
    public static long readLong(DataInput in) throws Exception {
        byte len = in.readByte();
        if (len == 0)
            return 0;
        byte[] buf = new byte[len];
        in.readFully(buf, 0, len);/*from  w  w  w. j a v a 2s.c  o  m*/
        return makeLong(buf, 0, len);
    }

    static long makeLong(byte[] buf, int offset, int len) {
        long retval = 0;
        for (int i = 0; i < len; i++) {
            byte b = buf[offset + i];
            retval |= ((long) b & 0xff) << (i * 8);
        }
        return retval;
    }
}

Related

  1. readLong(DataInput dataInput)
  2. readLong(DataInput in)
  3. readLongSequence(DataInput in)
  4. readLongUTF8(DataInput in)