标签:
JNI jbyteArray转char*
char* ConvertJByteaArrayToChars(JNIEnv *env, jbyteArray bytearray)
{
char *chars = NULL;
jbyte *bytes;
bytes = env->GetByteArrayElements(bytearray, 0);
int chars_len = env->GetArrayLength(bytearray);
chars = new char[chars_len + 1];
memset(chars,0,chars_len + 1);
memcpy(chars, bytes, chars_len);
chars[chars_len] = 0;
env->ReleaseByteArrayElements(bytearray, bytes, 0);
return chars;
}
调用:
{
char *pmsg = ConvertJByteaArrayToChars(env,jmsgversion);
...
delete pmsg;
}
标签:
原文地址:http://www.cnblogs.com/fyqds/p/5354961.html