title: Returning jbyteArray from native c in Android
body: <p>I use native c to read data from an audio file to jbyte pointer. Now i want to send it to java as an jbyteArray. </p>
  
  <pre><code>jbyteArray Java_com_app_audio_player_readData(JNIEnv * env, jobject jobj,jstring readPath)
  {
  
  FILE *fin;
  const char *inFile= (*env)-&gt;GetStringUTFChars(env,readPath,0);
  fin = fopen(inFile, "r");
  
  fseek(fin, 0, SEEK_END); // seek to end of file
   int size = ftell(fin); // get current file pointer
  fseek(fin, 0, SEEK_SET);
  
  jbyte *data=(jbyte *)malloc(size*sizeof(jbyte));
  int charCnt = 0;
  
  charCnt=fread(data, 1, size, fin);
  
  
  jbyteArray result=(*env)-&gt;NewByteArray(env, size);
  
       //-- I want to convert data to jbyteArray and return it to java    
  
  fclose(fin);
   return result;
  
  }
  </code></pre>
  
  <p>How it is done?</p>