0

I use from CSVReader in java to import those large files in DataBase.

What method should I use if I want to know that I have the last line of the file and then the file ends?

my code is:

String pathFile = "D:\\";
String ifrsFileName = "test.csv";
int countToInput = 1000;
CSVReader ifrsReader = new CSVReader(new FileReader(pathFile + ifrsFileName));
String[] nextLine;
long counter = 0;
while ((nextLine = ifrsReader.readNext()) != null) {
            deposit = process.getEntityObject(nextLine);
            deposits.add(deposit);

            if (counter == countToInput - 1 ) {
                
                repository.insertToDB(deposits, connection, pstmt);
                
                counter = 0;
                deposits.clear();
                
            }

            counter++;
}

My problem is that after read 1000 records the last, my program ends and if there are less than 1000 records left, they will not be imported. thanks a lot

mehnet ali
  • 73
  • 3
  • 12

0 Answers0