Java String to Byte Array getBytes(String s, String charsetName)

Here you can find the source of getBytes(String s, String charsetName)

Description

get Bytes

Declaration

public static byte[] getBytes(String s, String charsetName) 

Method Source Code


//package com.java2s;
import java.io.UnsupportedEncodingException;

public class Main {
    public static byte[] getBytes(String s, String charsetName) {
        if (s == null) {
            return null;
        }//from w w w  .  j  a  v a 2s.  c  om
        try {
            return s.getBytes(charsetName);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. getBytes(String s)
  2. getBytes(String s)
  3. getBytes(String s)
  4. getBytes(String s)
  5. getBytes(String s)
  6. getBytes(String s, String encoding)
  7. getBytes(String s, String encoding)
  8. getBytes(String str)
  9. getBytes(String str)