Java Byte Array to String by Charset byteToString(Charset charset, byte[] data)

Here you can find the source of byteToString(Charset charset, byte[] data)

Description

byte To String

License

Open Source License

Declaration

public static String byteToString(Charset charset, byte[] data) 

Method Source Code


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

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

public class Main {

    public static String byteToString(Charset charset, byte[] data) {
        CharBuffer buffer = charset.decode(ByteBuffer.wrap(data));
        String str = new String(buffer.array());
        return str;
    }//from   w  w w .j  a va  2  s . com
}

Related

  1. asBytes(String string, Charset charset)
  2. bytesToString(byte[] bytes, Charset charset)
  3. byteToString(byte[] b, String charset)
  4. changeEncoding(byte[] byteArray, Charset charsetFrom, Charset charsetTo)
  5. charSequence2Bytes(CharSequence sb, Charset charset)
  6. charSetForBOM(byte[] buffer, int offset)
  7. convertCharset(byte[] content, Charset fromCharset, Charset toCharset)