Here you can find the source of getUnicodeByteArray(String str)
public static byte[] getUnicodeByteArray(String str)
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; public class Main { public static byte[] getUnicodeByteArray(String str) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); try {//w w w . j a v a 2 s. c o m for (int i = 0; i < str.length(); i++) { dos.writeChar((int) str.charAt(i)); } } catch (Exception e) { } return baos.toByteArray(); } }