FileReadLine()
Reads the current line from an open file (see FileOpen()) and moves the current line pointer of the file to the next line.
FileReadLine( file=any );
Returns: String
| Argument | Description |
|---|---|
|
file
any,
required
|
edit
The file object Alias: source, filepath, fileObj |
Examples
edit// Example reads lines of file one at a time into an array
filePath = "/path/to/file.txt"
openFile = fileopen( filePath, "read" );
lines = [];
// IMPORTANT: must close file, use try/catch/finally to do so
try {
while( !fileIsEoF( openFile ) ) {
arrayAppend( lines, fileReadLine( openFile ) );
}
} catch( any e ) {
rethrow;
} finally {
fileClose( openFile );
}
See also
- File handling
- FileOpen()
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)