Package util

Class ReadFile

java.lang.Object
util.ReadFile
Direct Known Subclasses:
ReadWord

public class ReadFile extends Object
ReadFile is used to read in a file from a given directory.
Since:
2023-02
  • Constructor Details

    • ReadFile

      public ReadFile(String directory)
      Initializes the ReadFile object and assigns directory.
      Parameters:
      directory - directory
  • Method Details

    • checkFileExists

      public boolean checkFileExists()
      Checks if a file exists.
      Returns:
      boolean
    • checkContentsEmpty

      public boolean checkContentsEmpty()
      Checks if the list of contents is empty.
      Returns:
      boolean
    • readFile

      public void readFile()
      Reads the file using the directory.Adds each line that isn't null to the contents.
    • getFileContents

      public List<String> getFileContents()
      Returns the file contents.
      Returns:
      List
    • getRandomElement

      public String getRandomElement()
      Gets a random element from the list.
      Returns:
      String
    • getDirectory

      public String getDirectory()
      Gets the directory.
      Returns:
      String
    • setDirectory

      public void setDirectory(String directory)
      Sets the directory.
      Parameters:
      directory -