Reads the lines from the given file and returns them as a list of strings. The returned strings include the line ends (such as \). You may need to trim each line with the help of the trim() function before processing it further, as illustrated in the example below.
read-lines(filename:string, encoding:string="UTF-8") -> list of string
Specifies the path to a file.
Specifies the encoding to use. The default encoding is 'UTF-8'.
Let's suppose that you need to process multiple files that reside in multiple directories on the computer where FlowForce Server is installed. All the directory paths are saved as a text file, where each line corresponds to a directory path, for example:
The job illustrated below consists of two steps. The first step calls the read-files function and collects all directory paths from the text file above into a list. The second step iterates through the list of paths and calls the list-files function for each item. Note that the path is also trimmed before processing, to ensure that none of the resulting strings contain spaces or new line characters.
If you expose this job as a Web service and access it at the default address and port from a browser, the browser outputs the contents of each directory, as a JSON array, for example: