Java ByteBuffer Decode decodeToString(ByteBuffer shaderInfoLogBuffer, IntBuffer size)

Here you can find the source of decodeToString(ByteBuffer shaderInfoLogBuffer, IntBuffer size)

Description

Decode the ByteBuffer into an UTF-8 String.

License

Open Source License

Parameter

Parameter Description
shaderInfoLogBuffer the ByteBuffer that contains textual information
size the first int in this buffer represents the size of shaderInfoLogBuffer

Return

the UTF-8 contents of shaderInfoLogBuffer

Declaration

public static String decodeToString(ByteBuffer shaderInfoLogBuffer,
        IntBuffer size) 

Method Source Code

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

import java.nio.ByteBuffer;

import java.nio.IntBuffer;
import java.nio.charset.Charset;

public class Main {
    private static final Charset CHARSET_UTF8 = Charset.forName("UTF-8");

    /**/*from  w  w  w  . ja  v a2s.  c  o  m*/
     * Decode the ByteBuffer into an UTF-8 String. The length of the ByteBuffer
     * to read is determined by the first int in the supplied IntBuffer.
     * 
     * @param shaderInfoLogBuffer the ByteBuffer that contains textual information
     * @param size the first int in this buffer represents the size of shaderInfoLogBuffer
     * @return the UTF-8 contents of shaderInfoLogBuffer
     */
    public static String decodeToString(ByteBuffer shaderInfoLogBuffer,
            IntBuffer size) {
        int s = size.get(0);
        byte[] bs = new byte[s];
        shaderInfoLogBuffer.get(bs, 0, bs.length);
        return new String(bs, CHARSET_UTF8);
    }
}

Related

  1. decodeStoredBits(ByteBuffer bb)
  2. decodeStringSequence(ByteBuffer bb)
  3. decodeThrowing(Charset charset, ByteBuffer in)
  4. decodeTime(byte firstByte, ByteBuffer buffer)
  5. decodeTimeWithoutSign(byte firstByte, ByteBuffer buffer)
  6. decodeUtf8(ByteBuffer bytes)
  7. decodeUTF8(ByteBuffer utf8Data)
  8. decodeUTF8(final ByteBuffer buf)
  9. fillBuf(InputStream in, ByteBuffer bytes, CharBuffer chars, CharsetDecoder decoder)