Android examples for java.lang:String UTF-8
Convert string to utf-8 byte array
import android.content.Context; import android.content.res.AssetManager; import android.os.Environment; import android.text.format.DateFormat; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URLDecoder; import java.net.URLEncoder; import java.util.ArrayList; public class Main{ public static byte[] getUtf_8bytes(String str) { try {//from w w w. ja v a 2 s . c om byte[] buff = str.getBytes("utf-8"); return buff; } catch (Exception e) { // TODO: handle exception LogUtil.e(e.getMessage()); } return null; } }