I have a csv file that currently has 20 lines of data. The data contains employee info and is in the following format:
first name, last name, Employee ID
So one
You can do something like this:
BufferedReader reader = new BufferedReader(new FileReader(<>));
List lines = new ArrayList<>();
String line = null;
while ((line = reader.readLine()) != null) {
lines.add(line);
}
System.out.println(lines.get(0));
With BufferedReader
you are able to read lines directly. This example reads the file line by line and stores the lines in an array list. You can access the lines after that by using lines.get(lineNumber)
.