I'm pretty new at this, and this is probably a pretty obvious answer. In my csv script, i'm trying to figure out how to read a csv file using the CSVReader class and write to a new csv file. The error is telling me writeNext(java.lang.String[]) cannot be applied to (java.lang.String). I've tried using a direct assignment and getString() method however nothing works. Any ideas?
I have the following code: UPDATED
public static void main(String[] args) throws IOException {
//read csv file
CSVReader reader = new CSVReader(new FileReader(ADDRESS_FILE));
//write to csv file
CSVWriter writer2 = new CSVWriter(new FileWriter("output.csv"), '\t');
String [] nextLine;
while ((nextLine = reader.readNext()) != null) {
System.out.println("Name: [" + nextLine[0] + "]\nAddress: [" + nextLine[1] + "]\nEmail: [" + nextLine[2] + "]");
String[] newRow = new String[] {nextLine[0],nextLine[2], nextLine[1]};
}
//writer2.writeNext(entries);
writer2.writeAll(newRow);
writer2.close();
}
Error: c:\java\examples\ETHImport.java:46: cannot find symbo symbol : variable newRow location: class ETHImport writer2.writeAll(newRow);
1 error
Thanks in advance.