Within your loop
while(skills != null) {
skills = Skills.readSkill(in);
}
You are reading until the end of file without printing anything.
That you finally got the data of the last line printed at
Skills.print();
is probably sourced by declaring the data field members as
static
too which are set when passing the data to the constructor at
return new Skills(name, optional, short_desc, stat_affinity, rank, next_Skill);
But that is just a guess because you have not shown us the declaration of these members and the constructor.
To print the data of each line you have to do that in the loop:
skills = Skills.readSkill(in);
while (skills != null) {
skills.print();
skills = Skills.readSkill(in);
}
Note also that I have used the returned object
skills
there to print and not the
static
function
Skills.print()
.
I suggest to re-read your Java tutorials about the use of
static
. Use
static
data members and functions only where necessary. One of the most important features of classes is that each instance has it's own copy of data members. But this does not apply when using
static
members.
I suggest to redesign the complete class to not use any
static
members (data and functions).