Skip to Content
avatar image
Former Member

File Upload & Download getByteArrayFromResourcePath

anyone can help me on this

from the coding , you can see that the getByteArrayFromResourcePath() is get from the local disk drive...

if i save the file in binary format in database , how to i retrieve back the file

pls advice

public void wdDoInit()
    //@@begin wdDoInit()
IWDAttributeInfo attInfo=wdContext.getNodeInfo().getAttribute(IPrivateDownView.IContextElement.SOURCE);
IWDModifiableBinaryType binaryType=(IWDModifiableBinaryType)attInfo.getModifiableSimpleType();
//String resourcePath=WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(),DownView.FILE_NAME);
String resourcePath="C:\tmnet.xls";
//}catch(WDAliasResolvingException e){
}catch(Exception e){
throw new WDRuntimeException(e);	

//@@begin others
private byte[] getByteArrayFromResourcePath(String resourcePath)
throws FileNotFoundException, IOException {
FileInputStream in = new FileInputStream(new File(resourcePath));
ByteArrayOutputStream out = new ByteArrayOutputStream();
int length;
byte[] part = new byte[10 * 1024];
while ((length = != -1) {
out.write(part, 0, length);
return out.toByteArray();

private static final String FILE_NAME = "tmnet.xls";

Message was edited by:

yzme yzme

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    May 09, 2007 at 08:10 AM

    Hi Yzme,

    This path is on your WAS and not of your local machine (unless you have everything local) and from which database are you talking of saving and retrieving from. Kindly specify.



    Add comment
    10|10000 characters needed characters exceeded

    • Former Member


      Please tell me how to upload file from local machine.

      I have successfully uploaded files by using File Upload UI element where I am able to select the required file.

      Now I have a requirement of picking up a file from desktop using the code.

      If I am simply giving the path "C:
      Folder\file.txt", it is searching on server.



  • avatar image
    Former Member
    May 09, 2007 at 08:13 AM


    This blog may help to you




    Add comment
    10|10000 characters needed characters exceeded