Class Reader

Object
Reader

public class Reader extends Object
This class is used only for the purposes of creating a file Scanner object and using that Scanner to read the entire contents of the file name that is provided. These contents are stored in an ArrayList and returned in one.
  • Constructor Details

    • Reader

      public Reader()
  • Method Details

    • getFileScanner

      private Scanner getFileScanner(String fileName)
      This method takes a parameter of a String and uses that String to create and return a file Scanner that will allow reading from the provided fileName. Note that this method is private, as all calls to it will be isolated to this class, i.e. the only call to this method is in the same class, in getFileContents(String fileName).
      Parameters:
      fileName -
      Returns:
      Scanner that uses the provided fileName parameter.
    • getFileContents

      public ArrayList<String> getFileContents(String fileName)
      Calls the getFileScanner(String fileName) method for the Scanner returned, using this Scanner, each line of the file is read and stored in the fileContents ArrayList. This ArrayList is returned once each line from the file has been read.
      Parameters:
      fileName -
      Returns:
      ArrayList containing each line of the file as an element.