I'm a relative newbie with Grails and opencsv. However, I have managed to use CSVReader fine and am able to read csv files and use them in my controllers just fine.
However, if I try to use the CSVWriter I just get an error when the following line is encountered -
CSVWriter writer = new CSVWriter(new FileWriter("/yourfile.csv"), '\t');
Error is -
Could not find matching constructor for: com.opencsv.CSVWriter(java.io.FileWriter, java.lang.String)
I have imported what I think I need to import, ie
import java.io.File
import java.io.FileWriter
import java.io.IOException
import com.opencsv.CSVReader
import com.opencsv.CSVWriter
Grails version is 2.1.1
Netbeans development environment
Any ideas? I've tried all sorts of variations to the above and just cannot instantiate the writer.
'\t'in grails will be recognized as an instance ofStringand in fact there's no such constructor that takesWriterandStringtry:CSVWriter writer = new CSVWriter(new FileWriter("/yourfile.csv"), '\t' as char);Woo hoo! That's done the trick. I now don't get the error, and I'm able to carry on with my project.
Many thanks indeed for this pointer, and for the super fast response.