Java ByteBuffer Decode decodeUTF8(final ByteBuffer buf)

Here you can find the source of decodeUTF8(final ByteBuffer buf)

Description

Decode the content of the given ByteBuffer, from its position to its limit, to a String.

License

Open Source License

Parameter

Parameter Description
buf the UTF-8 encoded buffer to convert

Return

the newly decoded string

Declaration

public static String decodeUTF8(final ByteBuffer buf) 

Method Source Code

//package com.java2s;
/*//  w w w.  j a v a2s.  c  o  m
 *
 * JMeta - Meta's java implementation
 *
 * Copyright (C) 2013-2015 Pablo Joubert
 * Copyright (C) 2013-2015 Thomas Lavocat
 * Copyright (C) 2013-2015 Nicolas Michon
 *
 * This file is part of JMeta.
 *
 * JMeta is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * JMeta is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

import java.nio.ByteBuffer;
import java.nio.charset.Charset;

public class Main {
    /**
     * Decode the content of the given ByteBuffer, from its position to its limit, to a String.
     *
     * @param buf the UTF-8 encoded buffer to convert
     * @return the newly decoded string
     */
    public static String decodeUTF8(final ByteBuffer buf) {
        return Charset.forName("UTF-8").decode(buf).toString();
    }
}

Related

  1. decodeTime(byte firstByte, ByteBuffer buffer)
  2. decodeTimeWithoutSign(byte firstByte, ByteBuffer buffer)
  3. decodeToString(ByteBuffer shaderInfoLogBuffer, IntBuffer size)
  4. decodeUtf8(ByteBuffer bytes)
  5. decodeUTF8(ByteBuffer utf8Data)
  6. fillBuf(InputStream in, ByteBuffer bytes, CharBuffer chars, CharsetDecoder decoder)
  7. readInputStreamReader(InputStream in, ByteBuffer bytes, CharBuffer chars, CharsetDecoder decoder, Object lock)