Read All Text
Verb: readAllText
Available from: <Standard>
Reads a text file and returns all its contents in a "Text" variable.
Syntax
readAllText --filepath(String) [--encoding(Nullable<EncodingType>)] [--fileSystem(FileSystem)] (List<String>)=lines (String)=value
Inputs
| Script | Designer | Required | AcceptedTypes | Description |
|---|---|---|---|---|
| --filepath | File path | Required | Text | Full path to the text file that should be read. |
| --encoding | Encoding | Optional | EncodingType | Character encoding to use when reading text file:
|
| --fileSystem | File system | Optional | File System | Connection variable to a file system.
1. To obtain the connection variable with an available file system, this connection must be established using one of the following commands: Connect to Dropbox, Connect to Google Drive or Connect to Microsoft Corporation OneDrive, which must be pre-configured in the Web Client. 2. If nothing is specified in this parameter, the local file system of the operating system is used as default. |
Outputs
| Script | Designer | AcceptedTypes | Description |
|---|---|---|---|
| value | File text | Text | Variable with the text content of the given file. |
Example
A text file is entered and read using the default coding and operating system file system. The text of the file is displayed through the Log Message command.
defVar --name fileText --type String
readAllText --filepath "readTextExample.txt" --encoding "Default" fileText=value
logMessage --message "File text: ${fileText}" --type "Info"
// Show in the IBM Robotic Process Automation Studio console the text of the given file.