Here you can find the source of getChars(ByteBuffer buf, int off, int count)
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) |
public static char[] getChars(ByteBuffer buf, int off, int count)
//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; } }