Here you can find the source of stringToUTF8Bytes(String str)
public static byte[] stringToUTF8Bytes(String str)
//package com.java2s; //License from project: Open Source License import java.nio.charset.Charset; public class Main { private static final Charset UTF8_CHARSET = Charset.forName("UTF-8"); public static byte[] stringToUTF8Bytes(String str) { if (str == null) return null; return str.getBytes(UTF8_CHARSET); }//from www . j a v a2 s .c om }