您的位置:首页 > 其它

如何输出某种编码的字符串,比如ISO-8859-1?

2017-10-16 09:08 239 查看
public class Atranslate {

   

    public static void main(String[] args) {

          String str = "aa" ;

          str =translate( str) ;

          System.out.print(str);

    }

    private static String translate(String str) {

        String tempStr = "" ;

        try {

            tempStr = new String(str.getBytes("ISO-8859-1"),"GBK");

            tempStr = tempStr.trim();

        } catch (Exception e) {

            // TODO Auto-generated catch block

            e.printStackTrace();

        }

        

        return tempStr;

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐