Java ASCII from toAsciiBytes(final String value)

Here you can find the source of toAsciiBytes(final String value)

Description

Convert specified String to a byte array.

License

Open Source License

Parameter

Parameter Description
value to convert to byte array

Return

the byte array value

Declaration

public static final byte[] toAsciiBytes(final String value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from www  .  j  a  v  a  2  s  .  co  m*/
     * Convert specified String to a byte array. 
     * 
     * @param value to convert to byte array
     * @return the byte array value
     */
    public static final byte[] toAsciiBytes(final String value) {
        byte[] result = new byte[value.length()];
        for (int i = 0; i < value.length(); i++) {
            result[i] = (byte) value.charAt(i);
        }
        return result;
    }
}

Related

  1. toAscii(String s)
  2. toASCII(String str)
  3. toAsciiArray(char[] carr)
  4. toAsciiByteArray(final char[] carr)
  5. toAsciiByteArray(String s)
  6. toAsciiBytes(String str)
  7. toAsciiChar(byte b)
  8. toAsciiChar(int i)
  9. toASCIICode(byte[] bts)