Interface FileManager

All Known Implementing Classes:
CSVManager

public interface FileManager
The Managers interface represents a collection manager that reads and writes objects from and to a file. It has two methods to read objects from a file and write objects to a file.
  • Method Summary

    Modifier and Type
    Method
    Description
    readFromFile(String pathToDataFile)
    Reads a file at the specified path and returns an ArrayList containing each line of the file as a string.
    void
    write(String pathToDataFile, String[] header, List<String> records)
    Writes a TreeSet of City objects to a file located at the specified path.
  • Method Details

    • readFromFile

      ArrayList<String> readFromFile(String pathToDataFile) throws IOException
      Reads a file at the specified path and returns an ArrayList containing each line of the file as a string.
      Parameters:
      pathToDataFile - The path to the file to read.
      Returns:
      An ArrayList containing each line of the file as a string.
      Throws:
      IOException - If there is an error reading the file.
    • write

      void write(String pathToDataFile, String[] header, List<String> records) throws IOException
      Writes a TreeSet of City objects to a file located at the specified path.
      Parameters:
      pathToDataFile - the path to the file to be written
      header - An array of strings representing the header row of the CSV file.
      records - An array of objects representing the records to write to the CSV file. Each record should be an array of objects corresponding to a row in the CSV file.
      Throws:
      IOException - if there was an error writing to the file