My value object has multiple lines say:
abc
xyz
pqr
mno
I want to convert these lines into upper case and simultaneously write into a csv file. Me below code only writes the last entry i.e. "mno" into the o/p file. Because it is overwriting over existing ones.
private Object transformFieldValue(Object value) throws IOException {
String upperCase = value.toString().toUpperCase();
File file = new File("andy.csv");
FileWriter fr=null;
try {
fr = new FileWriter(file);
fr.write(upperCase);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
fr.flush();
fr.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return upperCase;
}
How to achieve the result so that andy.csv reads like:
ABC
XYZ
PQR
MNO