Java tutorial
//package com.java2s; import java.io.UnsupportedEncodingException; public class Main { public static byte[] stringToByte(String str) { byte[] s2byte = null; try { s2byte = str.getBytes("GB2312"); } catch (UnsupportedEncodingException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } return s2byte; } }