I have seen answers online using arrays but i do not wish to use them as I want to read it from files.
Then modify that code. Read text from a file is basic
Java program.
When you use arrays you need a loop to create the array or read the data from the array. A File is no different you need a loop to read a line from the file.