Java InputStream Read Long readLong(InputStream i)

Here you can find the source of readLong(InputStream i)

Description

read Long

License

Apache License

Declaration

public static final long readLong(InputStream i) throws IOException 

Method Source Code

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

import java.io.EOFException;

import java.io.IOException;
import java.io.InputStream;

public class Main {
    public static final long readLong(InputStream i) throws IOException {
        return ((long) (readInt(i)) << 32) + (readInt(i) & 0xFFFFFFFFL);
    }/*from www . ja  v a  2  s  .c  o  m*/

    public static final int readInt(InputStream i) throws IOException,
            EOFException {
        InputStream in = i;
        int ch1 = in.read();
        int ch2 = in.read();
        int ch3 = in.read();
        int ch4 = in.read();
        if ((ch1 | ch2 | ch3 | ch4) < 0)
            throw new EOFException();
        return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
    }
}

Related

  1. readLong(InputStream in)
  2. readLong(InputStream in)
  3. readLong(InputStream in)
  4. readLong(InputStream in)