I'm fairly new to java and I believe the problem comes from my lack of understanding.
I am trying to read an Array List of CSV values. Below is my code:
public static void readFile(){
String line = "";
try{
BufferedReader br = new BufferedReader(new FileReader(Main.filepath));
while((line = br.readLine()) != null){ //reads whilst the next line is not null
fileData.add(line); //adds current line to array list
}
catch (Exception ex){
System.out.println("File Not Found"); //if file not found, print
}
}
public class Film{
public static void duration(){
readFile();
for (int i = 0; i < (fileData.size()); i++) {
//System.out.println(fileData);
String[] temp = fileData.get(1).split(",");
System.out.println(temp);
}
}
readFile()
reads the CSV file and saves each line as an element in an ArrayList
filedata
is the ArrayList
filepath
is the path to the file
The CSV file is in format "filmName,releaseDate,filmRating,filmGenre,filmDuration,filmScore"
I'm trying to get Film() to print out the release dates of every element in the ArrayList, however my output is:
[Ljava.lang.String;@6bf2d08e
[Ljava.lang.String;@5eb5c224
[Ljava.lang.String;@53e25b76
[Ljava.lang.String;@73a8dfcc
When I'm expecting something more like
1999
2007
1956
1987
Any help is appreciated.