How to convert a jstring
to a C++ std::string
?
CppMethod(const std::sting& cpp_str) {
std::cout << "The string on CPP side is" << cpp_str << std::endl;
}
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT void JNICALL Java_com_something_something_someClass_someMethod(JNIEnv * env,
jobject /*this_obj*/, jstring jstring_str)
{
std::string cpp_str;
// How to copy jstring_str into cpp_str??
CppMethod(cpp_str)
}
#ifdef __cplusplus
}
#endif
}
Basically, How can I get the content of jstring_str
into cpp_str
?