Here you can find the source of unicode2Byte(String s)
public static byte[] unicode2Byte(String s)
//package com.java2s; /*//from w w w .j ava 2s. com * BJAF - Beetle J2EE Application Framework * ???J2EE??????????? * ??????2003-2015 ??? (www.beetlesoft.net) * * ?????????????????? *<http://www.apache.org/licenses/LICENSE-2.0> *???????????????????????? * * ??????????????????????????????? * ??? <yuhaodong@gmail.com/>. */ public class Main { public static byte[] unicode2Byte(String s) { int len = s.length(); byte abyte[] = new byte[len << 1]; int j = 0; for (int i = 0; i < len; i++) { char c = s.charAt(i); abyte[j++] = (byte) (c & 0xff); abyte[j++] = (byte) (c >> 8); } return abyte; } }