code: public static void readFully(final InputStream in, final byte[] buf, int off, final int len)
  			throws IOException {
  		int toRead = len;
  		while (toRead > 0) {
  			final int ret = in.read(buf, off, toRead);
  			if (ret < 0) {
  				throw new IOException("Premeture EOF from inputStream");
  			}
  			toRead -= ret;
  			off += ret;
  		}
  	}
docs: Reads len bytes in a loop.
  
  @param in
  The InputStream to read from
  @param buf
  The buffer to fill
  @param off
  offset from the buffer
  @param len
  the length of bytes to read
  @throws IOException
  if it could not read requested number of bytes for any reason (including EOF)