试试先转换成Unicode,再转成你需要的字符编码。getByte().
解决方案 »
- hibernate hql语句
- 文件下载读取流问题.
- 已知wsdl,调用该Web service的Java客户端代码应该怎么写?
- Dtree中createTree(Tree,1,7); 的问题
- spring与hibernate整合问题
- 如何规划学习java发展之路(学习过程)?困惑中.....
- 【求加精】Java247G教程整理永久链接,什么黑马都弱爆了
- jbuiler9 + weblogic7调试部署EJB的时候出错:datasource could not be located
- 请教,关于Persistence Layer
- 如家 汉庭 某酒店2000W数据 1.7 GB 泄露数据如何快速查询
- Hibernate 中检索调试有啥好办法
- 救命啦!jsp+tomcat+sql server运行问题!
try {
String temp_p = str;
byte[] temp_t = temp_p.getBytes("GBK");
String unicode = new String(temp_t,"ISO8859-1");
return unicode;
}
catch(Exception e) {
return "null";
}
}
//将strValue编码转换为GBK,防止乱码。
try{
byte buf[]=strValue.getBytes("ISO8859-1");
String string=new String(buf,"GBK");
String str=string;
return str;
}catch(Exception ex){
String eStr=null;
return eStr;
}
}
public static String toISO8859(String strValue){
//将strValue编码转换为GBK,防止乱码。
try{
byte buf[]=strValue.getBytes("GBK");
String string=new String(buf,"ISO8859-1");
String str=string;
return str;
}catch(Exception ex){
String eStr=null;
return eStr;
}
}
String tmp = new String(strUnicode.getBytes("UTF-16BE"), "GB2312");其中,tmp就是GB2312的字符串。strUnicode是转换前的字符串。