on 2005 Aug 02 6:59 AM
Hi,
I am trying to access a file which is stored within my project itself.
I wouold want to change the contents of the file at runtime. For this i have to access the file .
To access the file i dont want to give an absolute path when it is deployed in the server. How can i get a relative path.
Assuming i am storing this file in the lib folder of the project how will i access it without the absolute path
(I dont want to use http alias!)
Any help is appreciated..
Regards
Bharathwaj
Hi Bharat,
Try accessing the file by placing in the Mimes directory.
Regards, Anilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anil,
The problem is when i try to map it to a IFrame source it will take it , if its placed in mimes folder. But when i want to edit its contents i cant do it,because the File class needs a definite path and when i give the file name alone it is taking from <b> server0</b> folder.
So i guess i have to find the relative path.
And also when i use the http alias in
File f = new File("the alias");
its removing the "\".So it ends up like
http:\hostname:port\alias and not as http:
hostname:port\alias.
How to solve this ...!
Regards
Bharathwaj
Hi,
Thanks pascal. But it was not working. I tried this .
http:////localhost:port//somename
and it gave http:/localhost:port/somename.
Dunno why!
I solved it directly.It takes the path till server0 as default .After tat i appended the following
temp
webdynpro
web
local
appname
Components
componentspackage
the file.
Now its reading it.
I wanted a smaller path..But its ok! If anyone comes with better idea plz do share it ! That s y i am opening the question again !
Thanks for the help Anil and Pascal !
Regards
Bharathwaj
If you want to use an http connection so you can use the defined alias, you should use the URLConnection class (java.net.URLConnection) instead of the File class. You can use getInputStream() and getOutputStream() to read/write to the file.
The File class resolves any double /'s or \'s, because they have no meaning in filepaths.
Message was edited by: Pascal Willemsen
Hi Bharathwaj,
have a look at the WDURLGenerator API. This is what you need. You can put your file in the src/mimes/Components/<ComponentName> Folder and then you can access the file like this:
String path = null;
try
{
WDDeployableObjectPart dop = wdComponentAPI.getDeployableObjectPart();
path = WDURLGenerator.getResourcePath(dop, "example.txt");
}
catch (Exception e)
{
// do something
}
File f = new File(path);
Please post the soution
Regards, Anilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
68 | |
8 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.