Class DocumentIdentifier

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

public class DocumentIdentifier extends Object
class identifies the type of a document file and determines whether text files contain only ASCII characters.
  • Constructor Details

    • DocumentIdentifier

      public DocumentIdentifier()
  • Method Details

    • identify

      public static DocumentIdentifier.DocumentType identify(File file)
      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

      public static boolean isTextDocument(File file)
      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

      public static void main(String[] args)
      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