Can some one help me to read a file line by line,
I have this code - but this code will print all the content. I need to display only the 5th(or specific) line by line, hence I want to access and print any line dynamically. I need to print 5th line of the text file.
//read from file
myFile = new File("C:\\Documents and Settings\\ABCEDFG\\Desktop\\soapUI\\params.txt")
printFileLine = { log.info "File line: " + it }
myFile.eachLine(0, printFileLine)
Please help -Appreciate your help in advance!
^Thanks
It's sloppy and wasteful, but you can do
log.info "Line 5: " + myFile.readLines().get(4)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With