( documentation for Telosys generator version 4.0.0 )
This object allows to work with a file located on the filesystem
Each file instance is created with $fn.file(..) or $fn.fileFromXxx(..)
It can be any type of filesystem item (file or directory)
Example :
## Get file instance :
#set( $file = $fn.file('dir/foo.txt') )
#set( $file = $fn.fileFromBundle("foo.txt") )
#set( $file = $fn.fileFromModel('myfile.csv') )
## Use file instance :
#if( $file.exists() && $file.isFile() )
#set($content = $file.loadContent() )
#end
#foreach ( $line in $file.loadLines() )
> $line
#end
Since : 3.3.0
Attributes and methods |
.absolutePath : String
Returns the absolute pathname string. |
.canonicalPath : String
Returns the canonical pathname string. |
.exists() : boolean
Tests whether the file (or directory) exists |
.isDirectory() : boolean
Tests whether the file is a directory |
.isFile() : boolean
Tests whether the file is a 'normal file' |
.isHidden() : boolean
Tests whether the file is a 'hidden file' |
.length : long
Returns the length of the file |
.loadContent() : String
Loads all the lines of the file |
.loadContent(int n) : String
Same as loadContent() but ignore the first N lines |
.loadLines() : List
Loads all the lines of the file |
.loadLines(int n) : List
Same as loadLines() but ignore the first N lines |
.loadValues(String separator) : List
Loads values (split lines) from the file |
.loadValues(String separator, int n) : List
Same as loadValues(separator) but ignore the first N lines |
.name : String
Returns the name of the file or directory. |
.parent : String
Returns the pathname string for the file's parent |
.path : String
Returns the path for the file or directory. |