Fill up our buffer from the underlying input stream. Users of this
method must ensure that they use all characters in the buffer before
calling this method.

@exception  IOException  if an I/O error occurs.
347344
private void fill() throws IOException {
    int i = in.read(buf, 0, buf.length);
    if (i > 0) {
      pos = 0;
      count = i;
    }
  }
37684
private void fill() throws IOException {
    int n;
    previousBufferSize += nChars;
    do {
      n = in.read(cb, 0, cb.length);
    } while (n == 0);
    if (n > 0) {
      nChars = n;
      nextChar = 0;
    }
  }
260597
public int fill(ByteBuffer bb) throws IOException
    {
        return fill((dsts, offset, length)->ByteBuffers.move(bb, dsts, offset, length), fillSplitter);
    }
1055488
protected void drain() throws IOException {
        if (primitiveTypes == null || primitiveTypesBuffer == null) {
            return;
        }

        // If we got here we have a Stream previously created
        int offset = 0;
        byte[] written = primitiveTypesBuffer.toByteArray();
        // Normalize the primitive data
        while (offset < written.length) {
            int toWrite = written.length - offset > 1024 ? 1024
                    : written.length - offset;
            if (toWrite < 256) {
                output.writeByte(TC_BLOCKDATA);
                output.writeByte((byte) toWrite);
            } else {
                output.writeByte(TC_BLOCKDATALONG);
                output.writeInt(toWrite);
            }

            // write primitive types we had and the marker of end-of-buffer
            output.write(written, offset, toWrite);
            offset += toWrite;
        }

        // and now we're clean to a state where we can write an object
        primitiveTypes = null;
        primitiveTypesBuffer = null;
    }
914975
private void flushBuffer() throws IOException
    {
        while (_flush.hasRemaining())
        {
            int len=_channel.write(_flush);
            if (len<0)
                throw new IOException("EOF");
            if (len==0)
            {
                // write channel full.  Try letting other threads have a go.
                Thread.yield();
                len=_channel.write(_flush);
                if (len<0)
                    throw new IOException("EOF");
                if (len==0)
                {
                    // still full.  need to  block until it is writable.
                    if (_selector==null)
                     {
                            _selector=Selector.open();
                            _channel.register(_selector,SelectionKey.OP_WRITE);
                     }

                     _selector.select();
                }
            }
        }
    }
145213
public int fillWindow(ByteBuffer buffer) {
        assert !finishing;

        // Move the sliding window if needed.
        if (readPos >= bufSize - keepSizeAfter)
            moveWindow();

        // Try to fill the dictionary buffer. If it becomes full,
        // some of the input bytes may be left unused.
        int len = buffer.remaining();
        if (len > bufSize - writePos)
            len = bufSize - writePos;

        buffer.get(buf, writePos, len);
        writePos += len;

        // Set the new readLimit but only if there's enough data to allow
        // encoding of at least one more byte.
        if (writePos >= keepSizeAfter)
            readLimit = writePos - keepSizeAfter;

        processPendingBytes();

        // Tell the caller how much input we actually copied into
        // the dictionary.
        return len;
    }
6716
private static void writeAndFlush(
      final ByteBuffer buffer, final OutputStream outputStream) throws IOException {

    if (buffer.hasArray()) {
      outputStream.write(buffer.array(), buffer.position(), buffer.remaining());
    } else {
      // cannot access underlying byte array, need to copy into a temporary array
      while (buffer.hasRemaining()) {
        // figure out how much to read, but use an upper limit of 8kb. LogMessages should be rather
        // small so we don't expect this to get hit but avoid large temporary buffers, just in case.
        final int size = Math.min(buffer.remaining(), 8 * 1024);
        final byte[] chunk = new byte[size];
        buffer.get(chunk);
        outputStream.write(chunk);
      }
    }
    outputStream.flush();
  }
1316222
private boolean fillLast() throws IOException {
        int count;

        if (lastFilled == pageSize) {
            throw new IllegalStateException();
        }
        count = src.read(pages[lastNo], lastFilled, pageSize - lastFilled);
        if (count <= 0) {
            if (count == 0) {
                throw new IllegalStateException();
            }
            return false;
        }
        lastFilled += count;
        return true;
    }
861361
public byte readByte() throws IOException {

		// buffer depleted ?
		if (head == tail) {
			head = 0;
			// Refill.
			tail = input.read(buffer, head, bufSize);
			if (tail == -1) {
				// no more data available.
				throw new IOException("No more data is available");
			}
		}

		return buffer[head++];
	}
970371
private void processInput(boolean endOfInput) throws IOException {
        // Prepare decoderIn for reading
        decoderIn.flip();
        CoderResult coderResult;
        while (true) {
            coderResult = decoder.decode(decoderIn, decoderOut, endOfInput);
            if (coderResult.isOverflow()) {
                flushOutput();
            } else if (coderResult.isUnderflow()) {
                break;
            } else {
                // The decoder is configured to replace malformed input and unmappable characters,
                // so we should not get here.
                throw new IOException("Unexpected coder result");
            }
        }
        // Discard the bytes that have been read
        decoderIn.compact();
    }
914202
protected void fill() throws IOException {
        ensureOpen();
        len = in.read(buf, 0, buf.length);
        if (len == -1) {
            throw new EOFException("Unexpected end of ZLIB input stream");
        }
        inf.setInput(buf, 0, len);
    }
328510
private void refreshBuffer() throws IOException {
    if (output == null) {
      // We're writing to a single buffer.
      throw new OutOfSpaceException();
    }

    // Since we have an output stream, this is our buffer
    // and buffer offset == 0
    output.write(buffer, 0, position);
    position = 0;
  }
499466
private void fillBuf() throws IOException {
		int result = in.read(buf, 0, buf.length);
		if (result == -1) {
			throw new EOFException();
		}
		pos = 0;
		end = result;
	}
768131
def fill_inbuffer(self):
		
		if not self.connection:
			raise OmapiError("not connected")
		try:
			data = self.connection.recv(2048)
		except socket.error:
			self.close()
			raise
		if not data:
			self.close()
			raise OmapiError("connection closed")
		try:
			self.protocol.data_received(data)
		except OmapiSizeLimitError:
			self.close()
			raise
62225
public synchronized void finish() throws IOException
    {
        synchronized(out)
        {
            for(ByteArrayOutputStream baos : all_buffers)
            {
                baos.writeTo(out);
                baos.reset();
            }
            out.flush();
        }
        
    }
191430
public void flush() throws IOException {
    flushBuffer(true);
    out.flush();

    // if buffer is big, and last query doesn't use at least half of it, resize buffer to default value
    if (buf.length > SMALL_BUFFER_SIZE && cmdLength * 2 < buf.length) {
      buf = new byte[SMALL_BUFFER_SIZE];
    }

    if (cmdLength >= maxAllowedPacket) {
      throw new MaxAllowedPacketException(
          "query size (" + cmdLength + ") is >= to max_allowed_packet (" + maxAllowedPacket + ")",
          true);
    }
  }
657031
protected int fill (byte[] buffer, int offset, int count) throws KryoException {
		if (inputStream == null) return -1;
		try {
			return inputStream.read(buffer, offset, count);
		} catch (IOException ex) {
			throw new KryoException(ex);
		}
	}