Hi Bro,
you have to mention, exactly in which way you wanna see the records in the CSV file. Otherwise if it's a simply ArrayList to CSV file conversion then,follow the simple program below (Still i think, you might have some special requirements, that's what you have to mention specifically):
import java.io.*;
import java.util.ArrayList;
public class CSVWriter{
private static BufferedWriter writeInto = null;
private static File newFile = null;
public static void main(
String args[]){
ArrayList holdValues = new ArrayList();
holdValues.add("10");
holdValues.add("20");
holdValues.add("30");
holdValues.add("40");
holdValues.add("50");
holdValues.add("60");
try{
newFile = new File("d:\\Test\\try.csv");
writeInto = new BufferedWriter(new FileWriter(newFile));
for(int index=0;index<holdValues.size();index++){
String temp = (String)holdValues.get(index);
writeInto.write(temp,0,temp.length());
if(index != holdValues.size()-1){
writeInto.write(',');
}
}
}
catch(IOException ex){
System.out.println("Exception in File operation:"+ex);
}
finally{
try{
writeInto.flush();
writeInto.close();
}
catch(IOException exc){
exc.printStackTrace();
}
}
}
}
[ January 11, 2007: Message edited by: Subhadip Chatterjee ]