I am trying to read big CSV and TSV (tab-separated) Files with about 1,000,000 rows or more. Now I tried to read a TSV containing ~2,500,000 lines with OpenCSV, but it throws a java.lang.NullPointerException. It works with smaller TSV files with ~250,000 lines. So I was wondering if there are any other libraries that support the reading of huge CSV and TSV files. Do you have any ideas?

Everybody who is interested in my code (I shorten it, so try-catch is obviously invalid):

InputStreamReader in = null;
CSVReader reader = null;
try {
    in = this.replaceBackSlashes();
    reader = new CSVReader(in, this.seperator, '\"', this.offset);
    ret = reader.readAll();
} finally {
    try {
        reader.close();
    } 
}

This is the method where I construct the InputStreamReader:

private InputStreamReader replaceBackSlashes() throws Exception {
    FileInputStream fis = null;
    Scanner in = null;
    try {
        fis = new FileInputStream(this.csvFile);
        in = new Scanner(fis, this.encoding);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        
        while (in.hasNext()) {
            String nextLine = in.nextLine().replace("\\", "/");
            // nextLine = nextLine.replaceAll(" ", "");
            nextLine = nextLine.replaceAll("'", "");
            out.write(nextLine.getBytes());
            out.write("\n".getBytes());
        }
        
        return new InputStreamReader(new ByteArrayInputStream(out.toByteArray()));
    } catch (Exception e) {
        in.close();
        fis.close();
        this.logger.error("Problem at replaceBackSlashes", e);
    }
    throw new Exception();
}
Edit
Report