Package edu.odu.cs.cs350
Class FilenameReader
java.lang.Object
edu.odu.cs.cs350.FilenameReader
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetFilename(String filePath) Reads the file, validates that the referenced file exists, and returns the filename as a string.
-
Constructor Details
-
FilenameReader
public FilenameReader()
-
-
Method Details
-
getFilename
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
-