Class FolderFileSystem

java.lang.Object
ch.epfl.cs107.play.io.FolderFileSystem
All Implemented Interfaces:
FileSystem

public class FolderFileSystem extends Object implements FileSystem
Implementation of file system, mirroring actual files on disk.
  • Constructor Details

    • FolderFileSystem

      public FolderFileSystem(FileSystem fallback, File folder)
      Creates a new file system using specified folder.
      Parameters:
      fallback - (FileSystem): secondary file system used on error, not null
      folder - (File): root, may be null
    • FolderFileSystem

      public FolderFileSystem(FileSystem fallback)
      Creates a new file system using current working directory.
      Parameters:
      fallback - (FileSystem): secondary file system used on error, not null
  • Method Details

    • read

      public InputStream read(String name) throws IOException
      Description copied from interface: FileSystem
      Open an existing file for read.
      Specified by:
      read in interface FileSystem
      Parameters:
      name - (String): unique identifier, not null
      Returns:
      (InputStream): content stream, not null
      Throws:
      IOException - if file cannot be open for read
    • write

      public OutputStream write(String name) throws IOException
      Description copied from interface: FileSystem
      Open file for write, previous content overwritten if any.
      Specified by:
      write in interface FileSystem
      Parameters:
      name - (String): unique identifier, not null
      Returns:
      (InputStream): content stream, not null
      Throws:
      IOException - if file cannot be open for write