String的编码方式转换与读取

import java.io.UnsupportedEncodingException;


public class UTF_GBK {


public static void main(String[] args) throws UnsupportedEncodingException {
// TODO Auto-generated method stub
byte[] s = new String("欢迎来到广州市").getBytes("GBK");
byte[] ss = new String(s,"GBK").getBytes("UTF-8");
System.out.println(new String(ss,"UTF-8"));
}


}

你可能感兴趣的:(java)