/** * Drains the ByteBufferDestination's buffer into the destination. By default this calls * {@link #flushBuffer(ByteBuffer)} with the specified buffer. Subclasses may override. * <p> * Do not call this method lightly! For some subclasses this is a very expensive operation. For example, * {@link MemoryMappedFileManager} will assume this method was called because the end of the mapped region * was reached during a text encoding operation and will {@linkplain MemoryMappedFileManager#remap() remap} its * buffer. * </p><p> * To just flush the buffered contents to the underlying stream, call * {@link #flushBuffer(ByteBuffer)} directly instead. * </p> * * @param buf the buffer whose contents to write the the destination * @return the specified buffer * @since 2.6 */ @Override public ByteBuffer drain(final ByteBuffer buf) { flushBuffer(buf); return buf; }
/** * Flushes any buffers. */ public synchronized void flush() { flushBuffer(byteBuffer); flushDestination(); }