在某一次JNI调用中(C++调用java的静态方法),传入参数为byte[]类型,把这个参数以GBK模式编码,抛出UnsupportedEncodingException异常,只有某一个特殊的平板,某一个特殊时刻(转码向服务器发送登录请求的协议字符串)才会出现,更诡异的是,重新编码一次又成功了,所以想问一下有没有人见到过类似的情况,任何信息只要觉得有帮助都会给分的。我无奈之下改了的代码如下: private static String getCodeType(int codeType)
{
switch(codeType)
{
case 0:
return "UTF-16LE";
case 1:
return "GBK";
case 2:
return "UTF-8";
default:
return "";
}
}

public static byte[] convertCharCode(byte[] bs, int inType, int outType)
{
for (int i = 0; i<3; i++){
try {
String s = new String(bs, getCodeType(inType));//在此抛出异常
byte[] arr =  s.getBytes(getCodeType(outType));
return arr;
} catch (UnsupportedEncodingException e) {
Log.e("ERROR!Unsupported!", e.getMessage());
} catch (Exception e){
Log.e("ERROR!", e.getMessage());
}
}
return null;
}