Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.EOFException; import java.io.IOException; import java.io.InputStream; public class Main { private static final byte[] BUFFER = new byte[8]; private static void readIntoBuffer(final InputStream is, final int length) throws IOException { int read = is.read(BUFFER, 0, length); if (read != length) { throw new EOFException(); } } }