java中的String.split("#")在jni层实现
#include <jni.h>
#include <string.h>
#include <android/log.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
decodeCustom(JNIEnv *env, jobject type, jstring keys, jint offset) {
jclass string_class = env->FindClass("java/lang/String");
jmethodID methodId = env->GetMethodID(string_class, "split",
"(Ljava/lang/String;)[Ljava/lang/String;");
jobjectArray array = (jobjectArray) env->CallObjectMethod(keys, methodId,
env->NewStringUTF("#"));
jsize size = env->GetArrayLength(array);
for (jint i = 0; i < size; i++) {
jstring value = (jstring) env->GetObjectArrayElement(array, i);
//转换为jstring类型并打印
LOGD("str is %s ", env->GetStringUTFChars(value, false));
//转换为jint类型并打印
LOGD("str is %d ", atoi(env->GetStringUTFChars(value, false)));
}
return keys;
}