Package edu.odu.cs.cs350
Class DocumentIdentifier
java.lang.Object
edu.odu.cs.cs350.DocumentIdentifier
class identifies the type of a document file
and determines whether text files contain only ASCII characters.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration for supported document types. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionIdentifies the type of document based on its file extension.static booleanisTextDocument(File file) Checks whether a given text file contains only ASCII characters.static voidMain method for identifying a document's type from the command line.
-
Constructor Details
-
DocumentIdentifier
public DocumentIdentifier()
-
-
Method Details
-
identify
Identifies the type of document based on its file extension.- Parameters:
file- the file to identify- Returns:
- DocumentType.PDF if the file is a PDF, DocumentType.ASCII_TEXT if the file is a text file, or DocumentType.UNSUPPORTED otherwise
-
isTextDocument
Checks whether a given text file contains only ASCII characters.- Parameters:
file- the text file to check- Returns:
- true if the file contains only ASCII characters (0–127), false otherwise
-
main
Main method for identifying a document's type from the command line. Usage: java DocumentIdentifier <file>- Parameters:
args- the command-line arguments, where args[0] is the file path
-