File variables can be used whenever a route starts with a File or FTP consumer
endpoint, which implies that the underlying message body is of
java.io.File
type. The file variables enable you to access various
parts of the file pathname, almost as if you were invoking the methods of the
java.io.File
class (in fact, the file language extracts the
information it needs from message headers that have been set by the File or FTP
endpoint).
Some of file variables return paths that are defined relative to a
starting directory, which is just the directory that is
specified in the File or FTP endpoint. For example, the following File consumer
endpoint has the starting directory, ./filetransfer
(a relative
path):
file:filetransfer
The following FTP consumer endpoint has the starting directory,
./ftptransfer
(a relative path):
ftp://myhost:2100/ftptransfer
In general, the file variables are named after corresponding methods on the
java.io.File
class. For example, the file:absolute
variable gives the value that would be returned by the
java.io.File.getAbsolute()
method.
![]() | Note |
---|---|
This naming convention is not strictly followed, however. For example, there
is no such method as
|
Table 4.1 shows all of the variable supported by the file language.
Table 4.1. Variables for the File Language
Variable | Type | Description |
---|---|---|
file:name | String | The pathname relative to the starting directory. |
file:name.ext | String | The file extension (characters following the last .
character in the pathname). |
file:name.noext | String | The pathname relative to the starting directory, omitting the file extension. |
file:onlyname | String | The final segment of the pathname. That is, the file name without the parent directory path. |
file:onlyname.noext | String | The final segment of the pathname, omitting the file extension. |
file:ext | String | The file extension (same as file:name.ext ). |
file:parent | String | The pathname of the parent directory, including the starting directory in the path. |
file:path | String | The file pathname, including the starting directory in the path. |
file:absolute | Boolean | true , if the starting directory was specified as an
absolute path; false , otherwise. |
file:absolute.path | String | The absolute pathname of the file. |
file:length | Long | The size of the referenced file. |
file:size | Long | Same as file:length . |
file:modified | java.util.Date | Date last modified. |