user3453784 user3453784 - 1 year ago 306
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 Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download