I need to edit csv files but the available packages I have seen to manipulate these files (com.opencsv and javacsv) do not edit based on the current state of the file, but always rewrite it. This code shows in a simplified way what I want to do:
import com.opencsv.*;
import java.io.File;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class mainLD {
public static void main(String[] args) {
CSVWriter csvWriter;
try {
csvWriter = new CSVWriter(new FileWriter("E:/archivo.csv");
String[] tes=new String[3];
tes[0]="Primero";
tes[1]="Segundo";
tes[2]="tercero";
csvWriter.writeNext(tes);
csvWriter.close();
}
catch(Exception ee) {
System.out.println("error");
}}}
With this code what I expected was that every time "csvWriter.writeNext (tees)" is executed in runs independent of the program, it is written in the following line of the csv file. That is, a new line is written each time the program is run, but the first line is always rewritten instead. On the other hand, in none of the two packages is there any method that requests as a parameter the line number to be written or a line break instruction. Would I have to use another bookstore? Or is there some method to help me in one of these two libraries (com.opencsv and javacsv)? Thank you.