Grails read data from file and store it in an object -


i trying read file within controller , store data in object, cant manage save properly. can help? new in groovy/grails...

file generals = new file("c:/grails/grails-3.3.0/ggts/test/data.txt") def line = generals.readlines() def date = new setdate(params) date.save()  date.title = ${line[0]} date.location = ${line[1]} date.description = ${line[2]} date.name = ${line[3]} date.email = ${line[4]}  date.save() 

you may change ${line[0]} "${line[0]}" , things alike if want use string interpolation.

and line list of string, change ${line[0]} line[0] ok.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -