Write code to convert string to byte array with UTF-8
import java.io.UnsupportedEncodingException; public class Main{ public static void main(String[] argv){ String str = "book2s.com"; System.out.println(java.util.Arrays.toString(str2byte(str))); }// w w w. j a v a2s. c o m public static byte[] str2byte(String str) throws UnsupportedEncodingException { return str.getBytes("UTF-8"); } }