Read a file from a Groovy Script Function

Hello!

I would like to be able to read an XML-file from a function in vFoglight. Files can be uploaded to a module through the interface but how do I get the file into a function? The search path etc.

I've tried

def list =  []
new File("colors.txt").eachLine() {
  ln->
  list.add(ln)
}
return list

def list =  []

new File("myfile.txt").eachLine() {

  ln->

  list.add(ln)

}

return list

with all kinds of things in File("here"), but a FileNotFoundException is thrown.

Thanks!

  • Martin,

    The location you work from is the FOGLIGHT_HOME directory. if you wanted to work of a temp directory you would need to specify the absolute path.

    IE:

    def list =  []


    new File("C:\\temp\\myfile.txt").eachLine() {


      ln->


      list.add(ln)


    }


    return list

    Example:

    Capture.JPG

    Capture1.JPG

    </Ryan>