Here you can find the source of getUtf8Bytes(String str)
Parameter | Description |
---|---|
str | Java string |
public static byte[] getUtf8Bytes(String str)
//package com.java2s; //License from project: LGPL import java.io.UnsupportedEncodingException; public class Main { /**/* w ww . java 2s.c o m*/ * Returns the passed string as a byte array containing the * string in UTF-8 representation. * @param str Java string * @return UTF-8 byte array */ public static byte[] getUtf8Bytes(String str) { try { return str.getBytes("UTF-8"); } catch (UnsupportedEncodingException uee) { return str.getBytes(); } } }