Home

Back

Contents

Next

Working with Dirctories and Paths

BeanShell supports the notion of a current working directory for commands that work with files. The cd() command can be used to change the working directory and pwd() can be used to display the current value. The BeanShell current working directory is stored in the variable bsh.cwd.

All commands that work with files respect the working directory, including the following:

pathToFile()

As a convenience for writing your own scripts and commands you can use the pathToFile() command to translate a relative file path to an absolute one relative to the current working directory. Absolute paths are unmodified.

absfilename = pathToFile( filename );

Path Names and Slashes

When working with path names you can generally just use forward slashes in BeanShell. Java localizes forward slashes to the approprate value under Windows environments. If you must use backslashes remember to escape them by doubling them:

dir("c:/Windows"); // ok
dir("c:\\Windows"); // ok


Home

Back

Contents

Next