on 07-03-2008 12:57 PM
Hi
I am creating aapplication in Web Dynpro (Java). It will be a simple file editor.
I don't know how I can get access to files on EP. I have to get a file from the EP content (for example Documents/test.txt), edit it and send the edited file to the EP content. How can I do it?
Hi,
If you place the file inside
<Drive Name>:\usr\sap\<server name>\<instance like JC00..>\j2ee\cluster\server0\
You can use the Obsolute path..
You can use code some thing like the following to get the file and you can sent.
File f = new File(".//version.txt");
wdComponentAPI.getMessageManager().reportWarning(" file path : "+f.toString());
version.txt if the file name present in server folder.
You can use FilInputStream or File Reader to read it.
You can send this file instance. Try this out. It must work.
Hope it helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It doesn't work 😕
I can see this file here - https://HOSTNAME:PORT/irj/go/km/docs/documents/test.txt
How can I get to it (read, change and replace)?
Edited by: Marcin Rozanski on Jul 3, 2008 6:51 PM
Hi,
Here are the links which will help you in reading text file from KM
/thread/90181 [original link is broken]
regards,
Pradeep
Hi,
i have same scenario for the XML file. you have to read the file from the KM (the location where u have stored) as a resource.
after reading the file i have created input fields to get the values from the file and later edition by user,from KM deleted the existing file and replaced the old one with the new one.
Here i am giving the code example:-
ArrayList arryList = new ArrayList();
arryList = kmevents.getAllEvents(Entity, msgMngr, userInfo);
public ArrayList getAllEvents(
String Entity,
IWDMessageManager mgr,
UserInfo info) {
//creates an instance of Userinfo
ArrayList arrayList = new ArrayList();
kmPath = FILE PATH
pathRID = RID.getRID(kmPath);
try {
collection =
(ICollection) resourseFactory.getResource(
pathRID,
resourseContext);
resourceList = collection.getChildren();
resourceListIterator = resourceList.listIterator();
int count = 0;
while (resourceListIterator.hasNext()) {
resource = resourceListIterator.next();
if (resource.isCollection()) {
ArrayList list = new ArrayList();
list = getAllEventsFromFolder(file Path + resource.getName());
int i = count;
for (int j = 0; i < (count + list.size()); i+, j+) {
arrayList.add(i, (IResource) list.get(j));
}
count = i;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return arrayList;
}
public ArrayList getAllEventsFromFolder(String folderName) {
//creates an instance of Userinfo
ArrayList arrayList = new ArrayList();
RID pathRID = RID.getRID(folderName);
try {
ICollection collection =
(ICollection) resourseFactory.getResource(
pathRID,
resourseContext);
IResourceList resourceList = collection.getChildren();
IResourceListIterator resourceListIterator =
resourceList.listIterator();
while (resourceListIterator.hasNext()) {
resource = resourceListIterator.next();
if (resource.isCollection()) {
continue;
} else
arrayList.add(resource);
}
} catch (Exception e) {
e.printStackTrace();
}
return arrayList;
}
Hope that may help you.....
Regards,
Deepak
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.