Passing byte array back to Java
843829Oct 19 2001 — edited Oct 24 2001In Java when I am calling the getBytes(bytes) I do not know the size of the byte array. Only in the C++ code I will know how long the Byte Array is going to be.
In C++ I just want to copy "cbytes" into "jbytes" such that I will be able to make use of it in Java.
Java Code:
----------------
private static native int getBytes(byte[] bytes);
.
.
byte[] bytes = null;
int status = getBytes(bytes)
..
..
C++ Code
---------------
JNIEXPORT jint JNICALL Java_getBytes
(JNIEnv *, jclass, jbyteArray jbytes)
{
char * cbytes = getCBytes();
//
return 0;
}
Could some one let me know how this can be achieved.
Thanks