Java UTF8 UTF8GetString(final byte[] bytes, final int index, final int count)

Here you can find the source of UTF8GetString(final byte[] bytes, final int index, final int count)

Description

Decodes a range of bytes from a byte array into a string.

License

Open Source License

Parameter

Parameter Description
bytes The byte array containing the sequence of bytes to decode.
index The index of the first byte to decode.
count The number of bytes to decode.

Return

A string that contains the results of decoding the specified sequence of bytes.

Declaration

public static String UTF8GetString(final byte[] bytes, final int index, final int count) 

Method Source Code


//package com.java2s;
// Licensed under the MIT license. See License.txt in the project root.

import java.nio.charset.Charset;

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

    /**/* ww  w .j  a v  a 2 s .  co m*/
     * Decodes all the bytes in the specified byte array into a string.
     *
     * @param bytes The byte array containing the sequence of bytes to decode.
     * @return A string that contains the results of decoding the specified sequence of bytes.
     */
    public static String UTF8GetString(final byte[] bytes) {
        final String result = new String(bytes, UTF8);
        return result;
    }

    /**
     * Decodes a range of bytes from a byte array into a string.
     *
     * @param bytes The byte array containing the sequence of bytes to decode.
     * @param index The index of the first byte to decode.
     * @param count The number of bytes to decode.
     * @return A string that contains the results of decoding the specified sequence of bytes.
     */
    public static String UTF8GetString(final byte[] bytes, final int index, final int count) {
        final String result = new String(bytes, index, count, UTF8);
        return result;
    }
}

Related

  1. utf8ByteLength(String string)
  2. utf8BytesToString(byte[] bytes, int start, int length)
  3. utf8BytesToString(final byte[] in_utf8Bytes)
  4. utf8CharLen(byte byte1)
  5. UTF8GetBytes(final String value)
  6. utf8Len(byte b)
  7. utf8Length(byte[] buffer, int str, int len)
  8. utf8Replace(String str)
  9. utf8SafeCEscape(String src)