I'm trying to extract the username and password from a properties file containing :
#Fri May 31 09:33:22 CEST 2013
password=user40_31-05-2013
username=user40_31-05-2013
File propertiesFile = new File('testdata.properties')
def config = new ConfigSlurper().parse(propertiesFile.toURL())
println(config.username)
I'm having this error:
expecting '!', found 'F' @ line 1, column 2. #Fri May 31 09:33:22 CEST 2013 ^
1 error
thanks in advance
You can save having to close the stream yourself with the more idiomatic:
Use the Properties type:
Maybe I'm being an idiot here, but isn't the larger problem that he's using a shell-style comment character (#) instead of a groovy comment (// or /* ... */)?
His error message is because # at the beginning of a unix script should be followed by ! and then the path to an interpreter. (Something like #!/bin/sed)