Here you can find the source of readLong(InputStream in)
Parameter | Description |
---|---|
in | The InputStream to read the int from |
Parameter | Description |
---|---|
IOException | an exception |
public static long readLong(InputStream in) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStream; public class Main { /**//from w w w .j a v a2 s . c om * Read an long. * * @param in The InputStream to read the int from * @return The long read * @throws IOException */ public static long readLong(InputStream in) throws IOException { return ((long) in.read() << 56) | ((long) in.read() << 48) | ((long) in.read() << 40) | ((long) in.read() << 32) | ((long) in.read() << 24) | ((long) in.read() << 16) | ((long) in.read() << 8) | (long) in.read(); } /** * Read a number of bytes. * * @param in The InputStream to read from * @param length Number of bytes to read * @return An array containing the bytes read * @throws IOException */ public static byte[] read(InputStream in, int length) throws IOException { byte[] data = new byte[length]; int read = 0; while (read != length) { read += in.read(data, read, length - read); } return data; } }