Java Byte Array Decode decodeBytes(byte[] data, String encoding)

Here you can find the source of decodeBytes(byte[] data, String encoding)

Description

Returns the UTF-8 string corresponding to the specified bytes.

License

Apache License

Declaration

public static String decodeBytes(byte[] data, String encoding) 

Method Source Code


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

import java.io.UnsupportedEncodingException;

public class Main {
    /**/*from   www . j  av a2  s. c  om*/
     * Returns the UTF-8 string corresponding to the specified bytes.
     */
    public static String decodeBytes(byte[] data, String encoding) {
        try {
            return new String(data, encoding);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("Error decoding bytes with " + encoding, e);
        }
    }
}

Related

  1. decode(byte[] src, String charset)
  2. decode(Byte[] wrap)
  3. decode(final byte[] source, final int off, final int len)
  4. decode(String encoding, byte[] bytes)
  5. decode(String encoding, byte[] data)
  6. decodeObject(byte[] bytes)
  7. decodeObject(final byte[] bytes)
  8. decodeRequestParameter(String string, String encoding, byte[] buffer)
  9. decodeString(byte[] bytearr)