Here you can find the source of readLong(InputStream in)
public static long readLong(InputStream in) throws IOException
//package com.java2s; /******************************************************************************* * The MIT License (MIT)/* ww w . j ava 2 s. co m*/ * * Copyright (c) 2016 Dalibor Drgo? <emptychannelmc@gmail.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. ******************************************************************************/ import java.io.EOFException; import java.io.IOException; import java.io.InputStream; public class Main { public static long readLong(InputStream in) throws IOException { long ch8 = in.read(); long ch7 = in.read(); long ch6 = in.read(); long ch5 = in.read(); long ch4 = in.read(); long ch3 = in.read(); long ch2 = in.read(); long ch1 = in.read(); if (ch1 < 0) { throw new EOFException(); } return ((ch1 << 56) | (ch2 << 48) | (ch3 << 40) | (ch4 << 32) | (ch5 << 24) | (ch6 << 16) | (ch7 << 8) | (ch8 << 0)); } public static long readLong(byte[] bt, int off) throws IOException { return ((long) bt[off++] | (bt[off++] << 8) | (bt[off++] << 16) | (bt[off++] << 24) | (bt[off++] << 32) | (bt[off++] << 40) | (bt[off++] << 48) | (bt[off++] << 56)); } }