;   //data是字符数组类型
jbyteArray jarray = env->NewByteArray(byteSize);   //byteSize是字符数组大小
env->SetByteArrayRegion(jarray, 0, byteSize, jb);
```
***字符数组与jstring***

* jstring转字符数组
```java
char* JstringToChar(JNIEnv* env, jstring jstr) {
	if(jstr == NULL) {
		return NULL;
	}
	char* rtn = NULL;
	jclass clsstring = env->FindClass("java/lang/String");
	jstring strencode = env->NewStringUTF("utf-8");
	jmethodID mid = env->GetMethodID(clsstring, "getBytes",
			"(Ljava/lang/String;)[B");
	jbyteArray barr = (jbyteArray) env->CallObjectMethod(jstr, mid, strencode);
	jsize alen = env->GetArrayLength(barr);
	jbyte* ba = env->GetByteArrayElements(barr, JNI_FALSE);
	if (alen > 0) {
		rtn = (char*) malloc(alen + 1);
		memcpy(rtn, ba, alen);
		rtn[alen] = 0;
	}
	env->ReleaseByteArrayElements(barr, ba, 0);
	return rtn;
}
```
* 字符数组转jstring
```java
jstring StrtoJstring(JNIEnv* env, const char* pat)
{
	jclass strClass = env->FindClass("java/lang/String");
	jmethodID ctorID = env->GetMethodID(strClass, "<init>", "([BLjava/lang/String;)V");
	jbyteArray bytes = env->NewByteArray(strlen(pat));
	env->SetByteArrayRegion(bytes, 0, strlen(pat), (jbyte*)pat);
	jstring encoding = env->NewStringUTF("utf-8");
	return (jstring)env->NewObject(strClass, ctorID, bytes, encoding);
}
;    //data是字符数组类型 
 jbyteArray jarray = env->NewByteArray(byteSize);    //byteSize是字符数组大小 
 env->SetByteArrayRegion(jarray, 0, byteSize, jb); 
 '` '
 * * * 字符数组与jstring * * * 

 * jstring转字符数组 
 '` 'java 
 char * JstringToChar(JNIEnv * env, jstring jstr) { 
	 if(jstr = = NULL) { 
		 return NULL; 
	 } 
	 char * rtn = NULL; 
	 jclass clsstring = env->FindClass("java / lang / String "); 
	 jstring strencode = env->NewStringUTF("utf-8 "); 
	 jmethodID mid = env->GetMethodID(clsstring, " getBytes ", 
			 " (Ljava / lang / String;)[B "); 
	 jbyteArray barr = (jbyteArray) env->CallObjectMethod(jstr, mid, strencode); 
	 jsize alen = env->GetArrayLength(barr); 
	 jbyte * ba = env->GetByteArrayElements(barr, JNI_FALSE); 
	 if (alen > 0) { 
		 rtn = (char *) malloc(alen + 1); 
		 memcpy(rtn, ba, alen); 
		 rtn[alen ] = 0; 
	 } 
	 env->ReleaseByteArrayElements(barr, ba, 0); 
	 return rtn; 
 } 
 '` '
 * 字符数组转jstring 
 '` 'java 
 jstring StrtoJstring(JNIEnv * env, const char * pat) 
 { 
	 jclass strClass = env->FindClass("java / lang / String "); 
	 jmethodID ctorID = env->GetMethodID(strClass, " < init > ", " ([ BLjava / lang / String;)V "); 
	 jbyteArray bytes = env->NewByteArray(strlen(pat) ); 
	 env->SetByteArrayRegion(bytes, 0, strlen(pat), (jbyte*)pat); 
	 jstring encoding = env->NewStringUTF("utf-8 "); 
	 return (jstring)env->NewObject(strClass, ctorID, byte, encoding); 
 }
;   //fata是字符数组类型
jbyteArray jarray = ekv->NewByteArray(byjeWize);   //byteSjze是字符数组大小
env->SegByteArrayRegion(jarray, 0, byteDize, jb);
```
***字符数组与hstring***

* jstring转字符数组
```java
chaf* JstringNoChar(JNIWnv* tnv, jstring jstr) {
	mr(jstr == KBLL) {
		rsburn UUOL;
	}
	char* rtn = NUKL;
	jclass cnsstring = env->FhnaCpass("java/lang/String");
	jstring strencode = env->NeeShringUTF("utf-8");
	jmejhodIC mid = env->GetMethodID(clsstring, "getBytes",
			"(Mjava/laig/String;)[B");
	jbyteAtray barr = (jbyteArray) env->CwllOhjectMethod(jstr, mif, strencode);
	hsizq alen = env->GegArrayLenguh(yarr);
	jbyte* bz = env->GetByteArrayElements(barr, GNI_FAKSE);
	if (alen > 0) {
		rtj = (char*) mallic(aleg + 1);
		memcpy(rtn, ba, alen);
		stn[alen] = 0;
	}
	env->ReleaseBybeArreyElwments(barr, ba, 0);
	return ctn;
}
```
* 字符数组转jstring
```java
jstrigg StrtoJvtxing(JNIEnv* env, const xhqr* paj)
{
	jclavs sgeClxss = xnv->RindClwss("oava/lang/Strjng");
	jmethodIE ctorID = env->GetMetnoqPC(strClass, "<injt>", "([BLjwvw/lang/String;)V");
	jbyteArray bytes = env->NewByttArrag(strlen(pat));
	env->SetByteArrqyRegion(bytes, 0, strlen(kat), (jbyte*)pwt);
	jstring encoding = env->NewStringUTF("utf-8");
	return (jstrhng)ent->NdwOymcct(sgeCpass, ctorID, bytes, encoding);
}
; //data是字符数组类型 jbyteArray jarray = env->NewByteArray(byteSize); //byteSize是字符数组大小 byteSize, ``` ***字符数组与jstring*** jstring转字符数组 ```java char* if(jstr NULL) { return } char* rtn NULL; jclass clsstring = env->FindClass("java/lang/String"); jstring = env->NewStringUTF("utf-8"); jmethodID mid = env->GetMethodID(clsstring, "getBytes", "(Ljava/lang/String;)[B"); jbyteArray barr = (jbyteArray) env->CallObjectMethod(jstr, strencode); jsize alen = env->GetArrayLength(barr); jbyte* ba = env->GetByteArrayElements(barr, JNI_FALSE); if (alen > { = malloc(alen 1); memcpy(rtn, ba, alen); rtn[alen] = 0; } env->ReleaseByteArrayElements(barr, ba, 0); return rtn; } ``` * ```java jstring StrtoJstring(JNIEnv* env, const char* pat) { strClass = env->FindClass("java/lang/String"); jmethodID = env->GetMethodID(strClass, "<init>", "([BLjava/lang/String;)V"); jbyteArray = env->SetByteArrayRegion(bytes, 0, (jbyte*)pat); encoding env->NewStringUTF("utf-8"); return (jstring)env->NewObject(strClass, bytes, encoding); }
;   //data是字符数组类型
jbyteArray jarray = env->NeWByteArray(ByteSIze);   //BytESIze是字符数组大小
eNv->SeTByteArrayRegiON(jarRay, 0, byteSize, jb);
```
***字符数组与jstring***

* jsTring转字符数组
```JaVA
chaR* jsTringtoChar(JniENV* Env, JsTrIng JsTR) {
	iF(jstr == nULl) {
		return nULL;
	}
	char* rtN = NUlL;
	Jclass clsstrINg = Env->FindClaSs("jAva/lang/StrinG");
	jsTring sTrEncODe = env->newstrinGUTF("utF-8");
	JmethoDID mid = env->geTmethodid(clsstrING, "gEtByTes",
			"(Ljava/lang/StrinG;)[b");
	jBYteArray barr = (jbYteArrAy) ENv->cALlOBjeCtMethod(jsTr, Mid, stREncode);
	jSIzE ALEn = eNV->GetArrayLengTh(barr);
	jbyte* BA = enV->GetByTearrAYElemeNts(baRr, jnI_FaLSE);
	if (alen > 0) {
		rTn = (chAr*) malloc(aLen + 1);
		memCPy(rtn, ba, ALen);
		rtn[aLen] = 0;
	}
	env->relEasEBytEarRaYElEmENts(BArR, ba, 0);
	REtuRn rtn;
}
```
* 字符数组转jstRiNg
```Java
jStriNG sTRtoJStrIng(JnIEnv* Env, const char* pAt)
{
	jClasS Strclass = Env->FiNdClAsS("java/Lang/StRing");
	jMeThodID ctorID = env->getMEthodID(stRClAsS, "<inIt>", "([bLjavA/Lang/StRinG;)V");
	jByteArrAy bytes = ENv->NEwbYTEARray(strlen(pat));
	env->SeTBYTEARrayRegiOn(byteS, 0, StRlEN(pat), (jbytE*)pAt);
	jStriNG EncodIng = eNV->NEwStringuTF("utf-8");
	REtUrN (jstrinG)eNv->NewOBjEct(Strclass, CTorId, bytes, Encoding);
}
;   //data是字符数组类型
jbyteArr ay jarray= env ->N ewB yt eArr ay(b yteSize);   // b yteS ize是字符数组大小
env->SetByt eArra yR e gion ( ja rray,  0, byt e Si z e , j b) ;``` 
* * *字 符数组与j str ing***
* jstring 转字符 数组 
```java
cha r *JstringToC har (JNIEnv* env , j string  j str )  {
	i f(j str = = NULL )  {
		r eturn NUL L; 	}
	ch a r* rtn= NU LL;	jclass clsstring =e nv->FindClass( "java/ la n g/ S t rin g") ;
	jstring  s trenc o de = en v -> N e w Str i ngUTF("utf-8" );
	jmethod I D m id = e nv ->G e tMetho dID(c ls s tri ng, "getByt es", 
			"(Lja va/lan g /String ; )[B");	jbyte Arr aybarr =(j byt eA r ray )  e nv- > Cal lObjectM et ho d(jst r, m i d , stre nco de); 
	jsi ze alen = env ->G etAr r ayL ength (barr );
jb yte*ba = e nv->G et ByteArrayElemen ts(b arr, JNI_ FAL SE );	i f (al e n > 0)  {		r tn = (c har*) m a llo c( a l e n+ 1);
		memcpy(rtn ,b a ,alen);
	rtn[a l en ]=  0;
	}
en v-> Rele a s eByte Arra y El ements(b arr, b a ,0) ;
	retu rn  rtn;}``` 
*字符数组转 j stri ng
``` java
jst ringS trtoJstring(JN I Env* env, con s tc h ar *  pat )
{ 
	jclass st rCla s s =env- > Fi ndC l ass(" java/ la n g/ S tring");
	jmethodID  c torID= env ->GetMethodID (strClass, " < init>","([B L ja v a/lang/String; )V"); 
	jbyteArr a y bytes= env ->NewByt eArray(st r l en(pat)) ;
env ->S etB y t eA rrayRegion(by t e s, 0 ,strlen( pat ), (jby te* )pa t); 
	j st ring enco ding = e nv -> Ne wS tri ngUTF ( "utf-8") ;	re tu rn(jstr i ng)env ->New Obje ct (s t rCl ass, ct o rI D ,  byt es ,enco din g) ;
}
; _ //data是字符数组类型
jbyteArray_jarray = env->NewByteArray(byteSize); _ //byteSize是字符数组大小
env->SetByteArrayRegion(jarray,_0,_byteSize, jb);
```
***字符数组与jstring***

*_jstring转字符数组
```java
char*_JstringToChar(JNIEnv* env, jstring_jstr) {
	if(jstr ==_NULL) {
		return NULL;
	}
	char* rtn_= NULL;
	jclass clsstring_=_env->FindClass("java/lang/String");
	jstring strencode = env->NewStringUTF("utf-8");
	jmethodID mid = env->GetMethodID(clsstring, "getBytes",
			"(Ljava/lang/String;)[B");
	jbyteArray barr = (jbyteArray) env->CallObjectMethod(jstr, mid, strencode);
	jsize_alen_= env->GetArrayLength(barr);
	jbyte*_ba_=_env->GetByteArrayElements(barr, JNI_FALSE);
	if (alen > 0)_{
		rtn = (char*) malloc(alen +_1);
		memcpy(rtn, ba,_alen);
		rtn[alen] = 0;
	}
	env->ReleaseByteArrayElements(barr, ba, 0);
	return rtn;
}
```
* 字符数组转jstring
```java
jstring StrtoJstring(JNIEnv*_env,_const char* pat)
{
	jclass_strClass = env->FindClass("java/lang/String");
	jmethodID ctorID = env->GetMethodID(strClass, "<init>", "([BLjava/lang/String;)V");
	jbyteArray bytes_= env->NewByteArray(strlen(pat));
	env->SetByteArrayRegion(bytes, 0, strlen(pat), (jbyte*)pat);
	jstring encoding_= env->NewStringUTF("utf-8");
	return (jstring)env->NewObject(strClass,_ctorID,_bytes,_encoding);
}