Java UTF8 Encode toUTF8(byte[] bytes)

Here you can find the source of toUTF8(byte[] bytes)

Description

Convert to UTF-8 bytes

License

Apache License

Parameter

Parameter Description
bytes a parameter

Declaration

public static String toUTF8(byte[] bytes) 

Method Source Code

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

import java.io.UnsupportedEncodingException;

public class Main {
    /**//from   ww  w  . j ava 2  s. com
     * Convert to UTF-8 bytes
     * 
     * @param bytes
     * @return
     */
    public static String toUTF8(byte[] bytes) {
        assert bytes != null;
        String str = null;
        try {
            str = new String(bytes, "utf-8"); //$NON-NLS-1$
        } catch (UnsupportedEncodingException e) {
        }
        return str;
    }
}

Related

  1. getUTF8Bytes(String string)
  2. getUTF8Bytes(String string)
  3. getUTF8Decoder(boolean ignoreEncodingErrors)
  4. getUTF8StringLength(String string)
  5. isUTF8(String encoding)
  6. toUTF8(String content)
  7. toUTF8(String isoString)
  8. toUTF8(String s)
  9. toUTF8(String sourceStr)