user3453784 user3453784 - 7 months ago 138
Java Question

Reading the last line of CSV file using openCSV in Java

How to read only the last line of a csv file using openCSV.? Is there any way instead of reading the entire file.

Answer

If you don't need to use openCSV, you could use an implementation around RandomAccessFile. Here is a nice, working function (two actually, but one is more generic). Take into account the warnings in the end of that answer.

Also, Apache Commons has ReversedLinesFileReader, with readLine method that "returns the lines of the file from bottom to top", though it should be tested if the entire file is not being read.