on 12-17-2007 12:22 PM
Hello experts,
Can i create a temp file in a WD Project and then read and modify it at runtime.
If possible can you please tell me how this can be done
Thanks and Regards,
G. Singh
What exactly is your use case?
You could place the file inside src/mimes/components/<component> and read/modify it at runtime.
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can use . properties file in project, to read data. but you are not able to edit data in the project files.
If you create any temp.txt in server0 location . and you can edit from there.
see this below code
// this code create temp.txt file in server location \usr\sap\j2ee\jcxx\j2ee\cluster\server0
FileWriter write=new FileWriter("temp.txt");
Regards,
Naga
Hello Naga,
According to the documents i have written the below code, but still i am unable to create a .txt file at the given location.
ResourceContext resourceContext = buildResourceContext();
//get a resource factory
IResourceFactory resourceFactory = ResourceFactory.getInstance();
//Get a RID from the current path to display
RID pathRID = RID.getRID("/userhome/" + ep5User.getDisplayId()+ "/favorites");
//Get a Iresource object to work on
IResource resource = resourceFactory.getResource(pathRID, resourceContext);
ICollection folder = (ICollection) resourceFactory.getResource(pathRID,buildResourceContext());
folder.createResource("test.txt",null);
Can you please suggest something??
Kind Regards,
Gursimran Singh
Hi
use this below code and add the Sharing reference to ur wdp project PORTAL:sap.com/com.sap.km.application
try {
// get ep5 User
IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
com.sapportals.portal.security.usermanagement.IUser ep5User = WPUMFactory.getUserFactory().getEP5User(sapUser);
//create resource context
IResourceContext resourceContext = new ResourceContext(ep5User);
//get a resource factory
IResourceFactory resourceFactory = ResourceFactory.getInstance();
//Get a RID from the current path to create
RID pathRID = RID.getRID("/userhome/" + ep5User.getDisplayId()+ "/favorites");//make sure this directory already exist
// Get a Iresource object to work on
IResource resource = resourceFactory.getResource(pathRID, resourceContext);
//get the collection
ICollection collection = (ICollection) resource;
//creating content
String strs=" test file";
ByteArrayInputStream bbr=new ByteArrayInputStream(strs.getBytes());
IContent content=new Content(bbr,"text/plain",strs.length());
//create resource
collection.createResource("test.txt",null,content);
} catch (NotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (AccessDeniedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (WDUMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ResourceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UserManagementException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Do you need something like a .properties file? Could you explain in more detail what kind of file you need? What its supposed to be stored in there?
Regards.
Julio Herrera
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Have you try it with BufferedReader?
Regards,
Arnau Rovira
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
79 | |
9 | |
9 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.