Skip to content

Home

Development

IDEs

API Explorer

Releases

Release notes

Martini Runtime

Martini Desktop

Martini Online

Feature requests

Bug reports

FileMethods

The FileMethods class contains one-liner methods for reading and writing files in both Groovy and Gloop services. Here are some example usages:

Sample Gloop service showing how to use the `FileMethods` one-liners

 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