Java String Encode encode(String src, String charset)

Here you can find the source of encode(String src, String charset)

Description

encode

License

Open Source License

Declaration

public static byte[] encode(String src, String charset) 

Method Source Code


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

public class Main {
    public static byte[] encode(String src, String charset) {
        if (src == null) {
            return null;
        }//from ww w . j  a  v a2 s.  c o m
        try {
            return src.getBytes(charset);
        } catch (UnsupportedEncodingException e) {
            return src.getBytes();
        }
    }
}

Related

  1. encode(String s)
  2. encode(String s, String enc)
  3. encode(String s, String encoding)
  4. encode(String source, String charsetFrom, String charsetTo)
  5. encode(String src)
  6. encode(String str)
  7. encode(String str, int start, int end, Writer writer)
  8. encode(String text, String charset)
  9. encode(String text, String encoding)