Java Unicode Create getUnicodeByteArray(String str)

Here you can find the source of getUnicodeByteArray(String str)

Description

get Unicode Byte Array

License

Open Source License

Declaration

public static byte[] getUnicodeByteArray(String str) 

Method Source Code

//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();
    }
}

Related

  1. getUnicodeBytes(String s)
  2. getUnicodeString(byte bytes[], int offset, int len)
  3. getUnicodeString(byte[] d, int length, int pos)
  4. getUnicodeText(Object text)