Java ByteBuffer Flip flipToFlush(ByteBuffer buffer, int position)

Here you can find the source of flipToFlush(ByteBuffer buffer, int position)

Description

Flip the buffer to Flush mode.

License

Open Source License

Parameter

Parameter Description
buffer the buffer to be flipped
position The position of valid data to flip to. This should be the return value of the previous call to #flipToFill(ByteBuffer)

Declaration

public static void flipToFlush(ByteBuffer buffer, int position) 

Method Source Code

//package com.java2s;
//  are made available under the terms of the Eclipse Public License v1.0

import java.nio.ByteBuffer;

public class Main {
    /** Flip the buffer to Flush mode.
     * The limit is set to the first unused byte(the old position) and
     * the position is set to the passed position.
     * <p>//from   w w  w  .j  a  va  2  s.c  om
     * This method is used as a replacement of {@link Buffer#flip()}.
     * @param buffer   the buffer to be flipped
     * @param position The position of valid data to flip to. This should
     * be the return value of the previous call to {@link #flipToFill(ByteBuffer)}
     */
    public static void flipToFlush(ByteBuffer buffer, int position) {
        buffer.limit(buffer.position());
        buffer.position(position);
    }
}

Related

  1. flip(ByteBuffer bytes, int width, int height)
  2. flip(ByteBuffer[] buffers)
  3. flip(ByteBuffer[] bufs)
  4. flipPutFlip(ByteBuffer from, ByteBuffer to)
  5. flipToFill(ByteBuffer buffer)
  6. readAndFlip(ReadableByteChannel channel, ByteBuffer buffer, int bytes)
  7. transfer(@Nonnull final ByteBuffer aSrcBuffer, @Nonnull final ByteBuffer aDstBuffer, final boolean bNeedsFlip)