Here you can find the source of readLong(InputStream is)
public static long readLong(InputStream is) throws IOException
//package com.java2s; /**/*w ww.j a v a 2s. c o m*/ * Copyright (c) 2014-2015 by Wen Yu. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Any modifications to this file must keep this entire header intact. */ import java.io.ByteArrayOutputStream; import java.io.EOFException; import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; public class Main { public static long readLong(byte[] buf, int start_idx) { return ((buf[start_idx++] & 0xffL) | (((buf[start_idx++] & 0xffL) << 8) | ((buf[start_idx++] & 0xffL) << 16) | ((buf[start_idx++] & 0xffL) << 24) | ((buf[start_idx++] & 0xffL) << 32) | ((buf[start_idx++] & 0xffL) << 40) | ((buf[start_idx++] & 0xffL) << 48) | (buf[start_idx] & 0xffL) << 56)); } public static long readLong(InputStream is) throws IOException { byte[] buf = new byte[8]; readFully(is, buf); return (((buf[7] & 0xffL) << 56) | ((buf[6] & 0xffL) << 48) | ((buf[5] & 0xffL) << 40) | ((buf[4] & 0xffL) << 32) | ((buf[3] & 0xffL) << 24) | ((buf[2] & 0xffL) << 16) | ((buf[1] & 0xffL) << 8) | (buf[0] & 0xffL)); } public static byte[] readFully(InputStream is, int bufLen) throws IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream(bufLen); byte[] buf = new byte[bufLen]; int count = is.read(buf); while (count > 0) { bout.write(buf, 0, count); count = is.read(buf); } return bout.toByteArray(); } public static void readFully(InputStream is, byte b[]) throws IOException { readFully(is, b, 0, b.length); } public static void readFully(InputStream is, byte[] b, int off, int len) throws IOException { if (len < 0) throw new IndexOutOfBoundsException(); int n = 0; while (n < len) { int count = is.read(b, off + n, len - n); if (count < 0) throw new EOFException(); n += count; } } public static int read(InputStream is) throws IOException { return is.read(); } public static int read(InputStream is, byte[] bytes) throws IOException { return is.read(bytes); } public static int read(InputStream is, byte[] bytes, int off, int len) throws IOException { return is.read(bytes, off, len); } public static void write(OutputStream os, byte[] bytes) throws IOException { os.write(bytes); } public static void write(OutputStream os, byte[] bytes, int off, int len) throws IOException { os.write(bytes, off, len); } public static void write(OutputStream os, int abyte) throws IOException { os.write(abyte); } }