Java Charset Guess getCharSetStr(String str, String oldCharSet, String newCharSet)

Here you can find the source of getCharSetStr(String str, String oldCharSet, String newCharSet)

Description

get Char Set Str

License

Apache License

Declaration

public static String getCharSetStr(String str, String oldCharSet, String newCharSet) 

Method Source Code


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

import java.io.UnsupportedEncodingException;

public class Main {

    public static String getCharSetStr(String str, String oldCharSet, String newCharSet) {
        if (str == "" || str == null) {
            return "";
        }//from w w w.  j  a  v a 2s  . c  om
        try {
            str = new String(str.getBytes(oldCharSet), newCharSet);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return str;
    }
}

Related

  1. getCharset(File file)
  2. getCharset(Object resource)
  3. getCharsetFileWriter(File file, String charset)
  4. getCharsetFromBytes(byte abyte0[])
  5. getPYIndexChar(char strChinese, boolean bUpCase)