protected int readInt(InputStream in) throws IOException {
		
		int numRead = 0;
		int offset = 0;
		while (offset < intbuf.length && (numRead = in.read(intbuf, offset, intbuf.length)) >= 0)
			offset += numRead;

		if (offset < intbuf.length)
			throw new RuntimeException( "End of stream reached before reading enough bytes for an int" );
		
		int v = 0;
		
		for (int i = 0; i < intbuf.length; i++) {
			v |= (((int)intbuf[i]) & 0xff) << (i*8);
		}
		
		return v;
		
	}