Java tutorial
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static final String ENCODING = "UTF-8"; public static byte[] stringToByteArray(String s) { try { return s.getBytes(ENCODING); } catch (UnsupportedEncodingException ex) { return null; } } }