Here you can find the source of toUnicodeBytes(String str)
private static byte[] toUnicodeBytes(String str)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; public class Main { private static byte[] toUnicodeBytes(String str) { byte[] unicodeBytes = null; try {// www. j a va 2s. c om byte[] unicodeBytesWithQuotes = str.getBytes("Unicode"); unicodeBytes = new byte[unicodeBytesWithQuotes.length - 2]; System.arraycopy(unicodeBytesWithQuotes, 2, unicodeBytes, 0, unicodeBytesWithQuotes.length - 2); } catch (UnsupportedEncodingException e) { // This should never happen. e.printStackTrace(); } return unicodeBytes; } }