日期:2014-05-20 浏览次数:20928 次
JNIEXPORT jstring JNICALL Java_test_Test2_FlushBuffer (JNIEnv* env, jobject obj) { static char p[1024]; strcpy(p,str); strcpy(str,""); const jchar *jp = (jchar*)p; jcharArray ca = env->NewCharArray(1024); jclass jc = env->FindClass("java/lang/String"); jmethodID methodId = env->GetStaticMethodID(jc, "copyValueOf", "([C)Ljava/lang/String;"); env->SetCharArrayRegion(ca, 0, 1024,jp); char *a = NULL; //puts((char*)*jp); sprintf(a,"%d",123456); return (jstring)env->CallStaticObjectMethod(jc,methodId,ca); //return env->NewStringUTF(p); }