Here you can find the source of getUtf8Bytes(String str)
public static byte[] getUtf8Bytes(String str)
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; public class Main { public static byte[] getUtf8Bytes(String str) { if (hasLength(str)) { try { return str.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { ;//from w w w . j a va2 s .c o m } } return null; } public static boolean hasLength(CharSequence str) { return (str != null && str.length() > 0); } public static boolean hasLength(String str) { return hasLength((CharSequence) str); } }