Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Example added so we know what java.io.File returns for the tokens

...

Expression

Type

Description

file:name

String

refers to the file name

file:name.noext

String

refers to the file name with no extension

file:parent

String

refers to the file parent

file:path

String

refers to the file path

file:absolute.path

String

refers to the absolute file path

file:canonical.path

String

refers to the canonical path

file:length

Long

refers to the file length returned as a Long type

date:command:pattern

String

for date formatting using the java.text.SimepleDataFormat patterns. Is an extension to the Simple language. Additional command is: file for the last modified timestamp of the file. Notice: all the commands from the Simple language can also be used.

File token example

We have a java.io.File handle for the file hello.txt in the following directory: D:\project\camel\camel-core\target\filelanguage. The file tokens will return as:

Expression

Returns

file:name

hello.txt

file:name.noext

hello

file:parent

target\filelanguage

file:path

target\filelanguage\hello.txt

file:absolute.path

D:\project\camel\camel-core\target\filelanguage\hello.txt

file:canonical.path

D:\project\camel\camel-core\target\filelanguage\hello.txt

Samples

Lets assume we use the file consumer to read files and want to move the read files to backup folder with the current date as a sub folder. This can be archived using an expression like:

...