on 12-23-2009 4:16 AM
Hi Friends,
I have to store a file or document in to byte[] and have to set into RFC. I am able to save the document as resource and To get it back. But i have no idea that how to get this resource into byte[]. Please suggest me the approach i should follow.?
Thanks & Regards
Jeetendra
Hello,
You can read byte[] from the resource object that you created.
Suppose resource is of type IWDResource and you want to read it multiple times, then create
byte[] buffer = new byte[1024];
resource.read(true).read(buffer);
pass this buffer to your RFC.
Hope it helps
Abhinav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Abhinav,
byte[] buffer = new byte[1024]; // here How we can determine the exect size of array.?
resource.read(true).read(buffer);
when i am passing this buffer to RFC its throwing null pointer error.
java.lang.NullPointerException: while trying to invoke the method xxxx.com.node_check.node_check_app.comp.wdp.IPrivateNode_check_appCompView$IYsdkprodoccreate_InputElement.setI_Binary_Data(byte[]) of an object returned from xxxxx.com.node_check.node_check_app.comp.wdp.IPrivateNode_check_appCompView$IContextNode.currentYsdkprodoccreate_InputElement()
What may be the Reason.?
Thanks & Regards
Jeetendra
Hi Friends,
Thanks for all your response The problem get solved. i followed following Approach.
int c = -1;
int i = 0;
byte[] bArray;
while ((c = input.read()) != -1) {
out.write(c);
i++;
}
bArray = new byte<i>;
for(int j=0;j<=i;j++){
wdContext.currentContextElement().getResource().read(false).read(bArray);
}
Thanks & Regards
Jeetendra
If I remember correctly, the WDWebResource type can be converted to a File object. Next up just convert the File object to a byte array. Here's the File to byte[] array: [File to Byte Array|http://www.exampledepot.com/egs/java.io/File2ByteArray.html]
Goodluck!
Regards,
Jan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.