Java tutorial
//package com.java2s; import java.io.UnsupportedEncodingException; public class Main { public static byte[] stringToData(String string, String charsetName) { if (string != null) { try { return string.getBytes(charsetName); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } return null; } }