string subStr(const string& m, size_t to)
{
string retStr = "";
JniMethodInfo minfo;
if(JniHelper::getMethodInfo(minfo,"java/lang/String","substring","(II)Ljava/lang/String;")) //此处的分号不能少
{
jmethodID mid = minfo.env->GetMethodID(minfo.classID,"<init>","(Ljava/lang/String;)V");
jstring sss = minfo.env->NewStringUTF(m.c_str());
jobject self = minfo.env->NewObject(minfo.classID,mid,sss);
jstring s = (jstring)minfo.env->CallObjectMethod(self, minfo.methodID ,(jint)0,(jint)to);
retStr = JniHelper::jstring2string(s);
}
return retStr;
{
string retStr = "";
JniMethodInfo minfo;
if(JniHelper::getMethodInfo(minfo,"java/lang/String","substring","(II)Ljava/lang/String;")) //此处的分号不能少
{
jmethodID mid = minfo.env->GetMethodID(minfo.classID,"<init>","(Ljava/lang/String;)V");
jstring sss = minfo.env->NewStringUTF(m.c_str());
jobject self = minfo.env->NewObject(minfo.classID,mid,sss);
jstring s = (jstring)minfo.env->CallObjectMethod(self, minfo.methodID ,(jint)0,(jint)to);
retStr = JniHelper::jstring2string(s);
}
return retStr;
}
size_t countStr(const string& m)
{
jint len = 0;
JniMethodInfo minfo;
if(JniHelper::getMethodInfo(minfo,"java/lang/String","length","()I"))//此处的括号内不能有V
{
jmethodID mid = minfo.env->GetMethodID(minfo.classID,"<init>","(Ljava/lang/String;)V");
jstring sss = minfo.env->NewStringUTF(m.c_str());
jobject self = minfo.env->NewObject(minfo.classID,mid,sss);
len = (jint)minfo.env->CallIntMethod(self, minfo.methodID);
}
return len;
}