Java tutorial
//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 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)); } }