Surendra Kumar G P
Surendra Kumar G P

Reputation: 57

What is the groovy script to return contents of file?

I want to return the values of file in the return statement using groovy ?

ex: file has three lines abc,abd,abe then i should get output as return['abc','abd','abe']

Upvotes: 0

Views: 700

Answers (1)

Dónal
Dónal

Reputation: 187529

It sounds like you want to read the file contents into a list of Strings, with one list item for each line. The following will accomplish that:

List<String> fileContents = new File('/path/to/file.txt').readLines()

Upvotes: 3

Related Questions