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

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

Description

get Bytes

License

Open Source License

Declaration

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

Method Source Code

//package com.java2s;
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt

import java.io.UnsupportedEncodingException;

public class Main {
    public static byte[] getBytes(String s, String encoding) {
        byte[] bytes = null;
        if (s != null) {
            try {
                bytes = s.getBytes(encoding);
            } catch (UnsupportedEncodingException e) {
                bytes = s.getBytes();//from  w  w  w .  jav  a 2 s . co m
            }
        }
        return bytes;
    }
}

Related

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