Java ByteBuffer Get getChars(ByteBuffer buf, int off, int count)

Here you can find the source of getChars(ByteBuffer buf, int off, int count)

Description

Returns a character array from the buffer.

License

Apache License

Parameter

Parameter Description
buf The buffer
off Offset within the buffer where conversion will start
count The number of <em>characters</em> to retrieve (unlike other methods, which specify the number of bytes)

Declaration

public static char[] getChars(ByteBuffer buf, int off, int count) 

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.nio.ByteBuffer;

public class Main {
    /**/*from   w  w  w  .  j  ava 2s. c  om*/
     *  Returns a character array from the buffer. This method is equivalent to
     *  repeatedly calling <code>getChar()</code>.
     *
     *  @param  buf     The buffer
     *  @param  off     Offset within the buffer where conversion will start
     *  @param  count   The number of <em>characters</em> to retrieve (unlike
     *                  other methods, which specify the number of bytes)
     */
    public static char[] getChars(ByteBuffer buf, int off, int count) {
        char[] chars = new char[count];
        buf.position(off);
        for (int ii = 0; ii < count; ii++)
            chars[ii] = buf.getChar();
        return chars;
    }
}

Related

  1. getBufferBytes(ByteBuffer bb)
  2. getByte(ByteBuffer bb)
  3. getByte(ByteBuffer byteBuffer)
  4. getByteAsShort(java.nio.ByteBuffer buffer)
  5. getByteLen(ByteBuffer buffer)
  6. getCPCharacter(ByteBuffer buffer)
  7. getCrcChecksum(ByteBuffer buffer)
  8. getCRLFCRLFIndex(ByteBuffer buffer)
  9. getCRLFIndex(ByteBuffer buffer)