CharBuffer: arrayOffset() : CharBuffer « java.nio « Java by API






CharBuffer: arrayOffset()

  

import java.nio.CharBuffer;

public class Main {
  public static void main(String[] argv) throws Exception {
    CharBuffer buffer = CharBuffer.allocate(8);
    buffer.position(3).limit(5);
    CharBuffer sliceBuffer = buffer.slice();

    println(buffer);
    println(sliceBuffer);

    char[] myBuffer = new char[100];
    CharBuffer cb = CharBuffer.wrap(myBuffer);

    cb.position(12).limit(21);

    CharBuffer sliced = cb.slice();

    println(cb);
    println(sliced);
  }

  private static void println(CharBuffer cb) {
    System.out.println("pos=" + cb.position() + ", limit=" + cb.limit() + ", capacity="
        + cb.capacity() + ", arrayOffset=" + cb.arrayOffset());
  }
}

   
    
  








Related examples in the same category

1.CharBuffer: allocate(int capacity)
2.CharBuffer: array()
3.CharBuffer: capacity()
4.CharBuffer: flip()
5.CharBuffer: get()
6.CharBuffer: hasArray()
7.CharBuffer: hasRemaining()
8.CharBuffer: limit()
9.CharBuffer: limit(int newLimit)
10.CharBuffer: position()
11.CharBuffer: put(char c)
12.CharBuffer: put(String str)
13.CharBuffer: slice()
14.CharBuffer: subSequence(int start, int end)
15.CharBuffer: wrap(CharSequence csq)
16.CharBuffer: wrap(char[] array, int offset, int length)