Skip to content

Toro Cloud Dev Center


FileFunctions

The File class contains functions for reading and writing files in both Groovy and Gloop services. Here are some example usages:

Sample service showing how to use the `File` functions

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
// Declare a file object
def file = new File("packages/using-one-liners/resources/hello.txt")

// Declare a string object
def message = "Hello World!"

// Write to file
file.writeStringToFile(message)

// Read the contents of the file
def contents = file.readFileToString()

// Assert that the contents of the file is the message
assert contents == message