on 03-10-2008 2:26 AM
Hi There,
We need to read a text file from a fixed location to our WD application. need to read this text file content in a String and use it further.
We are on NW04 and so none of WDResource stuff will work for us :-(.
i tried this piece of code:
byte[] file_data_in_bytes = null;
//Get the selected file's contents in a byte array. returns null if no file is selected.
file_data_in_bytes = wdContext.currentContextElement().getCtx_va_FileData();
but file_data_in_bytes is null .. have attached contect variable Ctx_va_FileData to data property of upload UI.
Have i have missed out something.
Thanks for your time.
Rgds
Hi Sudhir,
Value attribute Ctx_va_Filedata must be of type Binary. Map this attribute to the fileupload UI datasource and try accessing it as wdcontext.currentcontextelement.get Ctx_va_Filedata.
Hope it is helpful.
Regards,
Saravanan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sudhir,
You should pass the bytes[] into the ByteArrayInputStream. Could you explain what exactly you are trying to implement?
For uploading file from the fixed path, it would be necessary to use file = new file(path). This path would be not from the local PC but from the Server where it is deployed. Evne I have tried doing the same. I would also like to wait for others ideas on this.
Regards,
Saravanan.
Hi,
Try out the following function
private void setByteArrayFromResourcePath(String resourcePath)
throws FileNotFoundException, IOException {
FileInputStream in = new FileInputStream(new File(resourcePath));
byte[] part = new byte[10 * 1024];
ByteArrayInputStream out = new ByteArrayInputStream(part);
int length;
while ((length = in.read(part)) != -1) {
out.read(part, 0, length);
}
in.close();
}
Regards
Ayyapparaj
Hi Saravanan,
I am trying to read a text file and need to pass its content to RFC.
Now this text file is generated by a script and is created with particular name and location.. i wanted to read this file and pass content to RFC.
You are right, as so far i could find a solution to autopick from client machine.
Rgds
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Data type should be of type Binary.
Pl go through this tutorial for NW04
Regards,
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot for your reply... I am using Binary data type only for reading it.
when i debugged the application. i saw condition
while ((line_of_file = bufferedReader.readLine()) == null)
is failing and thats why none of the value is being passed... is there something missing in this syntax..
Also if is possible to read a file from particular location, i.e. instead of use selecting a file though Upload UI, can we default the file location and upload it same way?
Regards,
Sudhir
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
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.