Java tutorial
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; public class Main { static String ENCODING = "utf-8"; public static byte[] getBytes(String str) { if (str == null) { str = ""; } try { return str.getBytes(ENCODING); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return null; } }