I need to update an existing entry in a CSV file using java code. The code that I have written is below. I'm able to match the entry given by the user with the entry in the file, but can't figure how to write a new entry at the same location.
while ((row = reader.readNext()) != null)
{
for (int i = 0; i < 1; i++)
{
System.out.print("row is "+row[i]);
// display CSV values
System.out.println("Cell Value: " + row[i]);
System.out.println("User Input: " + t1);
System.out.println("-------------");
if(t1.equals(row[0]))
{
data.add(new String[] { t1, t2, t3, t4, t5, t6, t7, t8, t9, t10,
t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22,
t23, t24, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35,
t36, t37, t38, t39
});
flag=1;
writer.writeAll(data);
break;
}
}
rowno++;
}