Java tutorial
//package com.java2s; import java.io.UnsupportedEncodingException; public class Main { public static byte[] strToBytes(String str, String charset) { try { return str.getBytes(charset); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } }