Java - Reading in a CSV file into a constructor

Java (Constructor issue)

Trying to figure out how to read in a CSV file into a constructor. Theme is harry potter and I'm reading in 4 files (Gryffindor, Hufflepuff, Ravenclaw, Slytherin). Reading this into my, but and have constructors/getters and setters as well. Supplied below.

private String name;

private String color;

private String professor;

public ArrayList Students;

public House(String name, String color, String professor, ArrayList stdList) { = name;

this.color = color;

this.professor = professor;

this.Students = stdList;


public void dataLoader() {

String fileName = "Gryffindor.csv";

String content = null;


Shows working path System.out.println(newFile(".").getAbsoluteFile());


try {

Scanner inputStream = new Scanner(new File(fileName));


Read More »

By: StackOverFlow - Saturday, 21 July

Related Posts