Java Byte Array Create toByteArray(String content, String charsetName)

Here you can find the source of toByteArray(String content, String charsetName)

Description

to Byte Array

License

Open Source License

Declaration

public static byte[] toByteArray(String content, String charsetName) 

Method Source Code

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

public class Main {
    public static byte[] toByteArray(String content, String charsetName) {
        byte[] bytes;
        try {/* w  w w. j a  va 2  s .c  o m*/
            bytes = content.getBytes(charsetName);
        } catch (Exception ex) { // CoreException, UnsupportedEncodingException
            bytes = content.getBytes();
        }
        return bytes;
    }
}

Related

  1. toByteArray(Object value)
  2. toByteArray(short foo)
  3. toByteArray(String address)
  4. toByteArray(String binString)
  5. toByteArray(String bytesStr, int byteLength)
  6. toByteArray(String hex)
  7. toByteArray(String hex)
  8. toByteArray(String hex)
  9. toByteArray(String hex)