View Full Version : Help needed with String Resolvers

04-23-2003, 11:00 AM

I'm sure there's an easy way to do this and that I'm just being stupid (as usual), but...

I have a Search File System wizard action that looks for a file in a few directories. In the next panel I want to be able to display the result to the user, BUT I don't want the whole path displayed, just the part before the actual file name.

i.e. something like this:

- searched /usr/bin, /usr/local etc for mysql

Display to user: MySQL was found in the following location: /usr/local

If I just use $W(searchBean.absolutePath) I get

/usr/local/mysql instead.

Any thoughts?

04-28-2003, 12:03 PM
You can use a combination of methods
from the String class. Something like

index = myDirectory.lastIndexOf("/")

baseDir = myDirectory.subString(0,index)

I would use the file.seperatorChar in
place of "/" so that it works on all OS's

04-28-2003, 07:08 PM
The FileService has methods to return the path and\or file name for a fully-qualified path on any platform. Take a lok at the "FileService.getParent()" and "FileService.getName()" methods. The first will return the parent folder for the path name specified. The second will return the filename portion of a given path.