Java ByteBuffer Slice slice(ByteBuffer buf, int pos, int limit)

Here you can find the source of slice(ByteBuffer buf, int pos, int limit)

Description

slice

License

Apache License

Declaration

public static ByteBuffer slice(ByteBuffer buf, int pos, int limit) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.nio.ByteBuffer;

public class Main {
    public static ByteBuffer slice(ByteBuffer buf, int pos, int limit) {
        int oldPos = buf.position();
        buf.position(pos);/*from ww  w . ja  va 2  s  . c o  m*/
        ByteBuffer result = buf.slice();
        result.limit(limit - pos);

        buf.position(oldPos);
        return result;
    }
}

Related

  1. getSlice(ByteBuffer bb, int offset, int length)
  2. preservingSlice(final ByteBuffer byteBuffer, final int position, final int limit)
  3. slice(ByteBuffer buf, int start, int end)
  4. slice(ByteBuffer data)
  5. slice(final ByteBuffer buffer, final int offset, final int length)
  6. slice(final ByteBuffer buffer, final int position)