Java ByteBuffer to String readString(ByteBuffer buf, int length)

Here you can find the source of readString(ByteBuffer buf, int length)

Description

Read string from ByteBuffer

License

Open Source License

Parameter

Parameter Description
buf Buffer
length Length of string

Return

String

Declaration

public static String readString(ByteBuffer buf, int length) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.nio.ByteBuffer;

public class Main {
    /**// w  ww.  j  a  v a 2  s  . c  om
     * Read string from ByteBuffer
     * @param buf       Buffer
     * @param length    Length of string
     * @return          String
     */
    public static String readString(ByteBuffer buf, int length) {
        byte[] buffer = new byte[length];
        buf.get(buffer);
        return new String(buffer);
    }
}

Related

  1. readString(ByteBuffer b, char s[], int off, int len)
  2. readString(ByteBuffer bb)
  3. readString(ByteBuffer bb)
  4. readString(ByteBuffer bb, int limit)
  5. readString(ByteBuffer buf)
  6. readString(ByteBuffer buff)
  7. readString(ByteBuffer buff, int len)
  8. readString(ByteBuffer buffer)
  9. readString(ByteBuffer buffer)