将String字符串转换为GB2312编码

StringBuilder sb = new StringBuilder();
sb.append("balalabala巴啦啦小魔仙01");
String utf8 = new String(sb.toString().getBytes("UTF-8"));
String unicode = new String(utf8.getBytes(), "UTF-8");
String gbk = new String(unicode.getBytes("GB2312"));

你可能感兴趣的:(java)