Here you can find the source of StringToByteArray(String input)
public static byte[] StringToByteArray(String input)
//package com.java2s; import java.nio.charset.Charset; public class Main { public static byte[] StringToByteArray(String input) { if (input == null || input.equals("")) return new byte[] {}; else/* w w w .j a va 2 s .c o m*/ return input.getBytes(Charset.forName("utf-8")); } }