Here you can find the source of readLong(InputStream in)
static public long readLong(InputStream in) throws IOException
//package com.java2s; //License from project: Apache License import java.io.EOFException; import java.io.IOException; import java.io.InputStream; public class Main { static public long readLong(InputStream in) throws IOException { byte[] buffer = new byte[8]; readFully(in, buffer, 0, 8);//from w ww. j a v a 2 s . co m return (((long) buffer[0] << 56) + ((long) (buffer[1] & 255) << 48) + ((long) (buffer[2] & 255) << 40) + ((long) (buffer[3] & 255) << 32) + ((long) (buffer[4] & 255) << 24) + ((buffer[5] & 255) << 16) + ((buffer[6] & 255) << 8) + ((buffer[7] & 255) << 0)); } static public void readFully(InputStream in, byte buff[]) throws IOException { readFully(in, buff, 0, buff.length); } static public void readFully(InputStream in, byte buff[], int offset, int length) throws IOException { if (length < 0) throw new IndexOutOfBoundsException(); int n = 0; while (n < length) { int count = in.read(buff, offset + n, length - n); if (count < 0) throw new EOFException(); n += count; } } static public byte[] read(InputStream in, int len) throws IOException { byte[] buff = new byte[len]; readFully(in, buff); return buff; } }