Wednesday, April 24, 2013

jni jnienv GetStringRegion example c c++ java


GetStringRegion

void GetStringRegion(JNIEnv *env, jstring str, jsize start, jsize len, jchar *buf);
Copies len number of Unicode characters beginning at offset start to the given buffer buf.
Throws StringIndexOutOfBoundsException on index overflow.
LINKAGE:
Index 220 in the JNIEnv interface function table.

Example of GetStringRegion

int len;
jchar *Src;

len = (*env)->GetStringLength(env, jSrc);
printf("Length of jSrc is %d\n", len);

Src = (jchar *)malloc((len + 1)*sizeof(jchar));
(*env)->GetStringRegion(env, jSrc, 0, len, Src);
Src[len] = '\0';
Example of GetStringRegion