肯定是GBK和UTF-8的转码了,用
TransFormat.GBToUnicode试试
附上源码
import java.io.UnsupportedEncodingException;
public class TransFormat
{
public TransFormat()
{
}
public static String unicodeToGB(String strIn)
{
String strOut = null;
if(strIn == null || strIn.trim().equals(""))
return strIn;
try
{
byte b[] = strIn.getBytes("GBK");
strOut = new String(b, "ISO8859_1");
}
catch(UnsupportedEncodingException unsupportedencodingexception) { }
return strOut;
}
public static String GBToUnicode(String strIn)
{
String strOut = null;
if(strIn == null || strIn.trim().equals(""))
return strIn;
try
{
byte b[] = strIn.getBytes("ISO8859_1");
strOut = new String(b, "GBK");
}
catch(Exception exception) { }
return strOut;
}
public static int GBlength(String strIn)
{
int len = 0;
String strOut = null;
if(strIn == null || strIn.trim().equals(""))
return 0;
try
{
byte b[] = strIn.getBytes("GBK");
len = b.length;
}
catch(Exception exception) { }
return len;
}
}
把你的java类设置成utf-8或者GB2312的,在mysql里也要改一下