Michael_Eddingt
17 years agoOccasional Contributor
GroovyDataSource and readLine issues
I have a Groovy DataSource with the following script. The script does not perform as one would expect. Instead each call to readLine() reads a line at some random spot way down the file (assuming the file is large enough). The expected result would be the first line, then the second, etc.
Could this be an issue with Groovy? Or something else?
The work around is to say "readLines()" and store the result in context. However, for large files this uses alot of memory.
// Read values from a text file.
if(context["peach"] == null)
{
context["peach"] = new File("c:/strings.txt").newInputStream()
}
result["value1"] = context["peach"].readLine()
// end
Could this be an issue with Groovy? Or something else?
The work around is to say "readLines()" and store the result in context. However, for large files this uses alot of memory.
// Read values from a text file.
if(context["peach"] == null)
{
context["peach"] = new File("c:/strings.txt").newInputStream()
}
result["value1"] = context["peach"].readLine()
// end