aspose file tools*
The moose likes Distributed Java and the fly likes convert jbyteArray into jString ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "convert jbyteArray into jString ?" Watch "convert jbyteArray into jString ?" New topic
Author

convert jbyteArray into jString ?

Abhra Kar
Ranch Hand

Joined: May 22, 2008
Posts: 124
Hi i have to convert a jbyteArray into jString
my java prog is ---JniEx1.java

class JniEx1{

private native String getMessage(byte[] b,int i);
public static void main(String args[]) {

String s="Hello World";
byte[] b=s.getBytes();

JniEx1 je1 = new JniEx1();
String msg = je1.getMessage(b,60);
System.out.println("User typed: " + msg);
}
static {
System.loadLibrary("Prompt");
}
}


generated method signature in JniEx1.h is
JNIEXPORT jstring JNICALL Java_JniEx1_getMessage
(JNIEnv *, jobject, jbyteArray, jint);



now in c file ------

#include <jni.h>
#include <stdio.h>
#include "JniEx1.h"

JNIEXPORT jstring JNICALL Java_JniEx1_getMessage(JNIEnv *env, jobject obj,jbyteArray jbr, jint ji)
{

.............................................................................................................
........................................................................................................



}



What i will write in the .... area to covert jbyteArray jbr into some Jstring variable ?

Abhra Kar
Ranch Hand

Joined: May 22, 2008
Posts: 124
Hi
waiting for help
please response

Thanks in advance
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11526
    
100

Have you looked at the JNI tutorial?


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Abhra Kar
Ranch Hand

Joined: May 22, 2008
Posts: 124
Thanks I have solve the problem
I have seen this tutorial earlier, I will read it in details later .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: convert jbyteArray into jString ?