Class FilenameReader

java.lang.Object
edu.odu.cs.cs350.FilenameReader

public class FilenameReader extends Object

This class reads the file path or file name and makes sure that the specified file exists. If it exists it returns the file name to the main class. If it does not exist it throws a FileNotFoundException.

  • Constructor Details

    • FilenameReader

      public FilenameReader()
  • Method Details

    • getFilename

      public static String getFilename(String filePath) throws FileNotFoundException
      Reads the file, validates that the referenced file exists, and returns the filename as a string.

      If the user enters a filename that does not correspond to an existing file on the filesystem, this method throws a FileNotFoundException.

      Parameters:
      filePath - the path to the file
      Returns:
      the validated filename
      Throws:
      FileNotFoundException - if the file does not exist or is not a regular file