Interface FileHandler<T>

All Known Implementing Classes:
LadderGameBoardFileHandlerGson, LudoBoardFileHandlerGson, PlayerFileHandlerCsv

public interface FileHandler<T>
Interface for handling files.

This interface defines methods for reading from and writing to a file. It uses a generic type T to represent the type of the file contents (e.g. Player, Board, etc.).

  • Method Summary

    Modifier and Type
    Method
    Description
    readFile(String filePath)
    Reads the contents of a file and returns the file contents.
    void
    writeFile(String filePath, List<T> contents)
    Writes contents to a file, using the given file path.
  • Method Details

    • readFile

      Object readFile(String filePath) throws IOException
      Reads the contents of a file and returns the file contents. The return type can be anything, as long as it is a valid object.
      Parameters:
      filePath - the path to the file
      Returns:
      The object read from the file
      Throws:
      IOException - if an error occurs while reading the file
    • writeFile

      void writeFile(String filePath, List<T> contents) throws IOException
      Writes contents to a file, using the given file path.
      Parameters:
      filePath - the path to the file
      contents - the list of contents to write to the file
      Throws:
      IOException - if an error occurs while writing to the file