Here is a tutorial that reads an input CSV file which is entirely numeric and uses ArrayList structures in Java on a Mac laptop to store the data of the file.
It is generic in the sense that integer or double data is allowed (the pattern is established by examining the first valid record) and delimiters of comma or space are allowed. Although the C in CSV stands for Comma (Separated Values) it is often the case that two files are functionally equivalent CSV files as far as behaviours go just by a redefinition of the delimiter, and often people use a space character as that delimiter.
CSV files have been a prominent form of data transmission ever since the early days of the PC’s first “killer app”, the spreadsheet. Without the spreadsheet in those early days, personal computing may not have taken off to the degree it has arrived at today.
As long as the first record is typical of the rest it should successfully fill an appropriate ArrayList with numerical file data.
The input file is asked using java.util.Scanner methods and the file is read using java.io.BufferedReader methods.
This link was very helpful regarding the reading of text files using Java, so, thanks.
Let’s see some Java programming code for this, and how it works in practice.
Download source code and rename to FileArrayList.java
If this was interesting you may be interested in this too.