Java ByteBuffer to String getString(ByteBuffer buf)

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

Description

Gets an RS2 string from the buffer.

License

Apache License

Parameter

Parameter Description
buf The buffer.

Return

The RS2 string.

Declaration

public static String getString(ByteBuffer buf) 

Method Source Code


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

import java.nio.ByteBuffer;

public class Main {
    /**/* w  ww.  j  a  v  a  2 s . c om*/
     * Gets an RS2 string from the buffer.
     * @param buf The buffer.
     * @return The RS2 string.
     */
    public static String getString(ByteBuffer buf) {
        StringBuilder bldr = new StringBuilder();
        char c;
        while ((c = (char) buf.get()) != 10) {
            bldr.append(c);
        }
        return bldr.toString();
    }
}

Related

  1. decodeString(ByteBuffer buffer, String charset)
  2. decodeString(ByteBuffer src)
  3. getStr(ByteBuffer buff)
  4. getString(@Nonnull final ByteBuffer src)
  5. getString(ByteBuffer bb)
  6. getString(ByteBuffer buf)
  7. getString(ByteBuffer buf)
  8. getString(ByteBuffer buf, Charset encoding)
  9. getString(ByteBuffer buf, int length, String charsetName)