Java ByteBuffer to String readString(ByteBuffer bb)

Here you can find the source of readString(ByteBuffer bb)

Description

read String

License

Open Source License

Declaration

public static String readString(ByteBuffer bb) 

Method Source Code


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

import java.nio.ByteBuffer;

public class Main {
    public static String readString(ByteBuffer bb) {
        int len = (int) bb.getShort();
        byte[] stringBytes = new byte[len];
        bb.get(stringBytes);/*from  w  w w  .j  a  v  a2  s  .  c  o  m*/

        return new String(stringBytes);
    }
}

Related

  1. getStringTrimmed(ByteBuffer buffer, int size)
  2. getStringWOLength(ByteBuffer bb)
  3. readStr(ByteBuffer bb, int off, int len)
  4. readString(byte[] tmp, ByteBuffer in)
  5. readString(ByteBuffer b, char s[], int off, int len)
  6. readString(ByteBuffer bb)
  7. readString(ByteBuffer bb, int limit)
  8. readString(ByteBuffer buf)
  9. readString(ByteBuffer buf, int length)