Java Byte Array Create toByteArray(String str)

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

Description

to Byte Array

License

Apache License

Declaration

static byte[] toByteArray(String str) 

Method Source Code

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

public class Main {
    static byte[] toByteArray(String str) {
        char[] chars = str.toCharArray();
        byte[] bytes = new byte[chars.length];

        for (int i = 0; i != bytes.length; i++) {
            bytes[i] = (byte) chars[i];
        }//  w  w w  .java 2s  . c  om

        return bytes;
    }
}

Related

  1. toByteArray(String map)
  2. toByteArray(String s)
  3. toByteArray(String source)
  4. toByteArray(String str)
  5. toByteArray(String str)
  6. toByteArray(String str, String separator)
  7. toByteArray(String string)
  8. toByteArray(String string)
  9. toByteArray(String strTransInfo)