import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; /** * Example of reading from files * in particular of reading from CSV files * * @author gtowell * Created: Feb 2021 */ public class Reader { /** * Read from the given file * @param fileName the name of the file to be read */ public void readOneLineTCR(String fileName) { try (BufferedReader br = new BufferedReader( new FileReader(fileName));) { int lineCount = 0; while (br.ready()) { lineCount++; String line = br.readLine(); String[] partsOfLine = line.split(","); //split the line at every comma for (int i = 0; i < partsOfLine.length; i++) { System.out.println(lineCount + " " + i + " " + partsOfLine[i]); } } } catch (FileNotFoundException e) { System.err.println("Opening issue " + e); } catch (IOException e) { System.err.println("Reading issue" + e); } } public static void main(String[] args) { Reader r = new Reader(); r.readOneLineTCR("aaa.csv"); } }