您将如何从使用 OpenCSV 库解析的文件中获取行号,其中出现特定条件?我希望在他们的 CSV 文件中用行号警告用户,只要该行上检测到潜在的错误值。
这是一段代码,我将文件解析为字符串数组:
try 
{
    CSVReader reader = new CSVReader(new FileReader(filePath), ',');
    // Reads the complete file into list of tokens.
    List<String[]> rowsAsTokens = null;
    try 
    {
        rowsAsTokens = reader.readAll();
    } 
    for(String[] row: rowsAsTokens) 
    {
        //Check for conditions within CSV file
    }
    catch (IOException e1)
    {
        e1.printStackTrace();
    }
}