Android String to Byte Array Convert StringToByteArray(String input)

Here you can find the source of StringToByteArray(String input)


String To Byte Array


public static byte[] StringToByteArray(String input) 

Method Source Code

//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"));


  1. getBytes(String data)
  2. getBytes(String data, String charsetName)
  3. getBytesFromAddress(String address)
  4. stringToBytes(String string)
  5. String2Byte(String hexString)
  6. StrToBcdBytes(String s)
  7. Str2Bcd(String asc)
  8. toBytes(String digits, int radix)
  9. toBytes(String hexString)