Java ByteBuffer to String readString(ByteBuffer buf)

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

Description

read String

License

LGPL

Declaration

public static String readString(ByteBuffer buf) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.nio.ByteBuffer;

public class Main {
    public static String readString(ByteBuffer buf) {
        StringBuilder bldr = new StringBuilder();
        char c = (char) buf.get();
        while (c != '\0') {
            bldr.append(c);/* ww w  .  j  a v  a 2 s .c om*/
            c = (char) buf.get();
        }
        return bldr.toString();
    }
}

Related

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