Question: I have a file reader class that opens a simple text file with either a single integer or string on each line with under 40

I have a file reader class that opens a simple text file with either a single integer or string on each line with under 40 lines total. I have another class who's constructor has a parameter that contains values I need to store. This class creates the layout of a board for a game and I want to have the parameter of my constructor (String bFile) to name a the file that is to be opened by my file reader class. I then want to take individual lines from bFile and store them in methods. For example I want to store the third line of bFile in a public method in the same class called length. I am practicing my java programming so I would appreciate any tips conforming to java syntax. Thanks in advance.

To clarify I want know how to open a file named by a constructor parameter (bFile), let's say it has to name "filename". Another class will open "filename" read it and so on. (the actual file name will be inputed by the user when ran) The constructor will then take the values read by the other class and store them in methods. I just want to know the basic syntax of these couple steps. Nothing to complicated. (especially how to take a certain line and store it in a method like getSize().)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!