Altova FlowForce Server 2024 Advanced Edition

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.

 

Signature

read-lines(filename:string, encoding:string="UTF-8") -> list of strings

 

Parameters

Name

Type

Description

filename

string

Specifies the path to a file.

encoding

string

Specifies the encoding to use. The default encoding is 'UTF-8'.

 

Examples

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:

 

C:\FlowForce\Examples\ListDirectories\1

C:\FlowForce\Examples\ListDirectories\2

C:\FlowForce\Examples\ListDirectories\3

 

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.

fs_func-read-lines-example-01

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:

fs_func-read-lines-example-02

© 2017-2023 Altova GmbH