To perform operations on files you whould firstly change to the directory where the file is.
For exampe, if you need to get to /root/directory/subdir/
you should call setPath three times
setPath(""); // to get to /root/
setPath("directory") // get to /root/directory/
setPath("subdir") // get to root/directory/subdir/
All the code written below is for J2ME
I use this method to set the path with separators (e.g. /root/dir/)
private void moveToDirectory(String dir) throws IOException {
RE r = new RE("/"); // where RE is me.regexp.RE
setDir("");
String[] dirs = r.split(dir);
for (int i = 1; i < dirs.length; i++) setDir(dirs[i]);
}
To delete a file you should open a PUT operation on it and close it, or use the delete method in ClientSession.
public void delete() throws IOException {
HeaderSet hs = cs.createHeaderSet(); // where cs is an opened ClientSession
hs.setHeader(HeaderSet.NAME, file); // file - is a filename String, no slashes should be used
cs.delete(hs);
}
If you need to replace a file you probably don't need to call delete method, just open OutputStream and write to it a new one
public OutputStream openOutputStream() throws IOException {
HeaderSet hs = cs.createHeaderSet();
hs.setHeader(HeaderSet.NAME, file);
Operation op = cs.put(hs); // Operation should be global, so you can close it after you done
return op.openOutputStream();
}
remember to close Operation after you done with the streams.