cheers justin wrote:Hi All,
I have a program that reads data from the database and writes into a csv file. I wants to write to multiple files instead of single file.
If the databse table contains 40 records then it should create 4 files with 10 record in each file.
Could anyone guide me in this regard.
Welcome to the ranch. You will need a variable keeping track of the number of rows read from the database. Once this reaches 10, new File(...)
And this will also mean you need to generate the file's name. From your existing posted code, lines 11 to 15 will eventually be inside the while loop (line 20). Remember to close each file too (line 45) inside the while loop.