cancel
Showing results for 
Search instead for 
Did you mean: 

Read file from mimes of webdynpro local development application

Former Member
0 Kudos

Hi,

I have placed a txt file in the mimies folder of webdynpro local development

path is

<b>C:\Documents and Settings\Administrator\.dtc\LocalDevelopment\DCs\sap.com\register\_comp\src\mimes\Components\com.sss.regionalmanagerapprovalform.RegionalManagerApprovalForm\a.txt</b>

I want to read the content of this file to my application.

so i wrote the code as,

FileInputstream in=new FileInputstream(""temp
webdynpro
web
local
sample
Components
com.sss.sample.Sample
com.sss.regionalmanagerapprovalform.RegionalManagerApprovalForm
a.txt");

int t=in.read();

but it throws file not found exception

What is the reason....?......plz help.

Please send me the code for reading the file from mimes.

Thanks in advance,

shami.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi:

Replace ur program with this code: Change the proj name, & proj path. it shud not give u any error.

String fileName = "temp
webdynpro
web
local
[ur proj name]
Components
[ur proj path]
docs.txt";

File f = new File(fileName);

try{

FileInputStream fis = new FileInputStream(f);

int t = fis.read();

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("t>"+t);

}catch(Exception e){

}

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(">>"+f.getPath());

Reply if any doubts.

Munna SAP

Former Member
0 Kudos

hi

I have changed my code as

<b> try

{

String fileName = "temp
webdynpro
web
local
sample
Components
com.sss.sample.Sample
a.txt";

File f = new File(fileName);

try{

FileInputStream fis = new FileInputStream(f);

int t = fis.read();

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("t>"+t);

}catch(Exception e){

wdComponentAPI.getMessageManager().reportSuccess("excep:"+e);

}

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(">>"+f.getPath());

}

catch(Exception e)

{

wdComponentAPI.getMessageManager().reportSuccess("exception in:"+e);

}</b>

I get the following exception

excep:java.io.FileNotFoundException: temp\webdynpro\web\local\sample\Components\com.sss.sample.Sample\a.txt (No such file or directory)

I have placed the file a.txt in C:\Documents and Settings\Administrator\Documents\SAP\workspace\sample\src\mimes\Components\com.sss.sample.Sample\a.txt

please help.

I want to read only text file.

Thanks in advance,

shami.

Former Member
0 Kudos

hi,

Once store your text file in location of the your local drive and goto the NWDS and close the application and open the application once again.

And verify the file is available over there or not I means to say mimes-components-<package name>-text file.

See this first

Former Member
0 Kudos

Hi Shami:

I think you have to go and place ur a.txt file here:

in webdynpro click on navigator > select ur proj 'sample' > src > mimes > Components > com.sss.sample.Sample > paste ur a.txt here in this directory.

and deploy it now.

u shudn't get any error now.

Munna SAP

Former Member
0 Kudos

hi,

I have paste my flie in in webdynpro click on navigator > select ur proj 'sample' > src > mimes > Components > com.sss.sample.Sample > paste ur a.txt here in this directory.

but still i get the same file not found exception......

Please help to read the text files from mimes....

Thanks in advance,

shami.

Former Member
0 Kudos

Just try with

File f = new File("a.txt"); instead of giving full path.

Regards,ANilkumar

Former Member
0 Kudos

hi,

I tried by giving the file name alone,

But still it gave the sane exception

excep:java.io.FileNotFoundException: a.txt (No such file or directory)

Please help.....

Thanks in advance,

shami

Former Member
0 Kudos

Hi,

right click on the project find the location of the your project.

And goto that location.find the file name in the mimes componenet and find ur name in the packages copy the path from there.

And goto the NWDS ans see the file avail the u can write ur code as Anils suggestion then it might helps u.

Thanks,

Lohi.

Former Member
0 Kudos

hi,

I went to the location of the file and from ther i took the path

The file is existing.

But still i get file not found exception. what is the reason.

Should I map this file with any ui eleemnt....

Please help...

Thanks in advance,

shami

Former Member
0 Kudos

Hi Shami,

First check the file part of the .ear or not ?

- Build the project. and go to the project folder in windows explorer and open the <project>.ear file.

Open the ear and open .wda file inside it.

Go to the components folder and check document .The doc should present in that component.

Now in the code no need to enter complete path.Just give the file name.

Regards, ANilkumar

Former Member
0 Kudos

hi,

Everything is rigtht but still i get the same error....FileNotFoundException

Please help me to read a txt file from mimes....

Thanks in advance,

shami.

Former Member

Hi Shami,

try this one instead of locating the file path manually:

String resourcePath = WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(), fileName);

Regards

Former Member
0 Kudos

Hi,

This link explains all your requirement.

https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/2dd3dbcd-0401-0010-55b8-b10808ff688e

Go thru this

or other wise use this code

IWDAttributeInfo attInfo = wdContext.currentContextElement().node().getNodeInfo().getAttribute("PdfSource");

ISimpleTypeModifiable type = attInfo.getModifiableSimpleType();

IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType) type;

binaryType.setFileName("TravelRequest.pdf");

binaryType.setMimeType(WDWebResourceType.PDF);

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

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);

}

thanks,

Lohi.