Here you can find the source of toBytesFromUnicode(String s)
public static byte[] toBytesFromUnicode(String s)
//package com.java2s; // it under the terms of the GNU General Public License as published by public class Main { public static byte[] toBytesFromUnicode(String s) { int limit = s.length() * 2; byte[] result = new byte[limit]; char c;//from ww w . j ava 2 s . co m for (int i = 0; i < limit; i++) { c = s.charAt(i >>> 1); result[i] = (byte) (((i & 1) == 0) ? c >>> 8 : c); } return result; } }