Questo contenuto non è disponibile nella lingua selezionata.

16.2. File Variables


Overview

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).

Starting directory

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
Copy to Clipboard Toggle word wrap
The following FTP consumer endpoint has the starting directory, ./ftptransfer (a relative path):
ftp://myhost:2100/ftptransfer
Copy to Clipboard Toggle word wrap

Naming convention of file variables

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 java.io.File.getSize().

Table of variables

Table 16.1, “Variables for the File Language” shows all of the variable supported by the file language.
Expand
Table 16.1. Variables for the File Language
VariableTypeDescription
file:nameStringThe pathname relative to the starting directory.
file:name.extStringThe file extension (characters following the last . character in the pathname). Supports file extensions with multiple dots, for example, .tar.gz.
file:name.ext.singleStringThe file extension (characters following the last . character in the pathname). If the file extension has mutiple dots, then this expression only returns the last part.
file:name.noextStringThe pathname relative to the starting directory, omitting the file extension.
file:name.noext.singleStringThe pathname relative to the starting directory, omitting the file extension. If the file extension has multiple dots, then this expression strips only the last part, and keep the others.
file:onlynameStringThe final segment of the pathname. That is, the file name without the parent directory path.
file:onlyname.noextStringThe final segment of the pathname, omitting the file extension.
file:onlyname.noext.singleStringThe final segment of the pathname, omitting the file extension. If the file extension has multiple dots, then this expression strips only the last part, and keep the others.
file:extStringThe file extension (same as file:name.ext).
file:parentStringThe pathname of the parent directory, including the starting directory in the path.
file:pathStringThe file pathname, including the starting directory in the path.
file:absoluteBooleantrue, if the starting directory was specified as an absolute path; false, otherwise.
file:absolute.pathStringThe absolute pathname of the file.
file:lengthLongThe size of the referenced file.
file:sizeLongSame as file:length.
file:modifiedjava.util.DateDate last modified.
Torna in cima
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2025 Red Hat