Here you can find the source of toUTF8(String string)
public static byte[] toUTF8(String string)
//package com.java2s; //License from project: Open Source License import java.nio.charset.Charset; public class Main { public static final Charset UTF_8 = Charset.forName("UTF-8"); /**/* w w w. ja va2s .c o m*/ * Encodes a String to UTF-8. */ public static byte[] toUTF8(String string) { return string.getBytes(UTF_8); } }