on 02-02-2007 9:16 AM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
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.
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
Hi Shami,
try this one instead of locating the file path manually:
String resourcePath = WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(), fileName);
Regards
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.