Android String to Byte Array Convert stringToBytes(String string)

Here you can find the source of stringToBytes(String string)


string To Bytes


Apache License


public static byte[] stringToBytes(String string) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.StringTokenizer;

public class Main {
    public static byte[] stringToBytes(String string) {
        StringTokenizer tokenizer = new StringTokenizer(string, ",");

        byte[] bytes = new byte[tokenizer.countTokens()];
        for (int k = 0; k < bytes.length; k++)
            bytes[k] = (byte) Integer.parseInt(tokenizer.nextToken());
        return bytes;
    }/*from   ww  w .  j  ava 2 s  .c  o  m*/


  1. bytesStorage(String str)
  2. getBytes(String s)
  3. getBytes(String data)
  4. getBytes(String data, String charsetName)
  5. getBytesFromAddress(String address)
  6. String2Byte(String hexString)
  7. StringToByteArray(String input)
  8. StrToBcdBytes(String s)
  9. Str2Bcd(String asc)