Java String Encode encodeString(String text, String charsetName)

Here you can find the source of encodeString(String text, String charsetName)

Description

encode String

License

Apache License

Declaration

public static String encodeString(String text, String charsetName) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.UnsupportedEncodingException;

public class Main {
    public static String encodeString(String text, String charsetName) {
        if (text != null) {
            byte bbb[] = text.getBytes();

            try {
                return new String(bbb, charsetName);
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();// w w  w. j  a v  a  2 s .  com
            }
            return text;
        }
        return text;
    }
}

Related

  1. encodeString(String s, Integer size)
  2. encodeString(String s, String charset)
  3. encodeString(String sourceString, String sysCharset, String charset)
  4. encodeString(String str)
  5. encodeString(String strData)
  6. encodeString(String value)
  7. encodeStringByUTF8(String str)
  8. encodeText(String str)
  9. encodeText(String str, String fromEnc, String toEnc)