@Override
	public synchronized int read() throws IOException
	{
		if (bsize == 0) return -1;
		int returnValue = buffer[offset];
		if (bsize == buffer.length)
		{
			int read = in.read();
			if (read != -1)
				buffer[offset] = (byte) read;
			else --bsize;
		} else {
			--bsize;
		}
		offset = (++offset) % buffer.length;
		return returnValue;
	}