cancel
Showing results for 
Search instead for 
Did you mean: 

File not found exception

Former Member
0 Kudos

Dear All,

I am trying to open a file which is located at

src/mimes/Components/com.sap.tut.wd.uploaddownloadinteractiveform.UploadDownloadInteractiveFormComp,

I am using this sample code given by sap..

*

IWDAttributeInfo attInfo =

wdContext.currentContextElement().node().getNodeInfo().

getAttribute("PdfSource");

ISimpleTypeModifiable type = attInfo.getModifiableSimpleType();

IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType) type;

binaryType.setFileName("TravelRequest.pdf"); // Set file name

binaryType.setMimeType(WDWebResourceType.PDF); // set the mime type

String fileName ="temp
webdynpro
web
local
TutWD_UploadDownloadInteractiveForm_Init
Components
com.sap.tut.wd.uploaddownloadinteractiveform.UploadDownloadInteractiveFormComp1
TravelRequest.pdf";

// path to the source file

/* converts the binary file to a byte array and moves it to the text element */

try

{

File file = new File(fileName);

FileInputStream in = new FileInputStream(file);

ByteArrayOutputStream out = new ByteArrayOutputStream();

int length;

byte[] part = new byte [10 * 1024];

while ((length = in.read(part)) != -1)

{

out.write(part, 0, length);

}

in.close();

wdContext.currentContextElement().

setPdfSource(out.toByteArray());

} catch(Exception e)

{

throw new WDRuntimeException(e);

}

*

But I am getting runtime exception...

java.io.FileNotFoundException: temp\webdynpro\web\local\TutWD_UploadDownloadInteractiveForm_Init\Components\com.sap.tut.wd.uploaddownloadinteractiveform.UploadDownloadInteractiveFormComp1\TravelRequest.pdf (The system cannot find the path specified)

Please tell me what could be the reason...

Thanks in Advance

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Amit,

The problem can be with relative path and absolute path.

You are passing relative path, it may be the case that it is not taking it.

Print the absolute path of file object you created.

OR

try passing absolute path while creating the file object.

It should work.

Regards,

Yogesh..

Former Member
0 Kudos

Hi,

If you are working with NW04S, you can check this tutorial for an example.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a...

Regards,

Harini S

P.S: Post this type of question in Webdynpro for Java forums.

Former Member
0 Kudos

Thanks Harini,

Using this solution I am able to download and upload the files, but please tell me where these files get stored after uploading (Plaese specify the full path).

Thanks a lot

srinivas_sistu
Active Contributor
0 Kudos

Hi,

Have a look at this PDF this may solve your problem.....

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/202a850a-58e0-2910-eeb3-bfc3e081...

I hope problem is with *** String fileName ****

Regards,

Srinivas.