Posted By:
Sammuel_Thumbsy
Posted On:
Friday, July 25, 2003 10:48 AM
Hello, I'm new to the JNI and I would like to know if there is a way to set the value of a jstring passed in as a method parameter. For example: /* wrapper code */ JNIEXPORT jint JNICALL Java_MyTest_setString (JNIEnv *env, jobject this, jstring outbuff, jint len) { int answer; char buff[512]; answer = SOMEFUNCTION(buff,512); /* obviously the strcpy won't work, */ /* but i need the data put into outbuff */ /* without creating a new outbuff. */ strcpy(outbuff,buff); return (jint) answer; } /* c code */ int SOMEFUNCTION(char *b, int len) { strncpy(char,DATA,len)
More>>
Hello,
I'm new to the JNI and I would like to know if there is a way to set the value of a jstring passed in as a method parameter.
For example:
/* wrapper code */
JNIEXPORT jint JNICALL Java_MyTest_setString
(JNIEnv *env, jobject this, jstring outbuff, jint len)
{
int answer;
char buff[512];
answer = SOMEFUNCTION(buff,512);
/* obviously the strcpy won't work, */
/* but i need the data put into outbuff */
/* without creating a new outbuff. */
strcpy(outbuff,buff);
return (jint) answer;
}
/* c code */
int SOMEFUNCTION(char *b, int len)
{
strncpy(char,DATA,len);
return 1;
}
<<Less