Java UTF8 utf8(String string)

Here you can find the source of utf8(String string)

Description

utf

License

LGPL

Declaration

public static byte[] utf8(String string) 

Method Source Code

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

public class Main {
    public static byte[] utf8(String string) {
        try {/*  w w  w . jav  a2  s .  c  o  m*/
            return string.getBytes("UTF-8");
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static String utf8(byte[] bytes) {
        try {
            return new String(bytes, "UTF-8");
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}

Related

  1. stringToUtf8(String str)
  2. stringToUTF8Bytes(String str)
  3. toBytesUTF8(String s)
  4. toBytesUTF8(String str)
  5. unZip(String zipFile, String outputFolder, boolean skipDirectory)
  6. utf8BufferByteLen(CharSequence str)
  7. utf8ByteLength(String string)
  8. utf8BytesToString(byte[] bytes, int start, int length)
  9. utf8BytesToString(final byte[] in_utf8Bytes)