Class FilenameUtils

java.lang.Object
com.digicert.validation.utils.FilenameUtils

public class FilenameUtils extends Object
Utility class for validating filenames.

The `FilenameUtils` class provides static methods for validating filenames. It ensures that filenames contain only allowed characters and do not exceed a maximum length. This class is useful for validating filenames before using them in file operations or storage.

  • Field Details

    • FILENAME_CHAR_PATTERN

      private static final Pattern FILENAME_CHAR_PATTERN
      Regex for one or more of the allowed char set for filename.
  • Constructor Details

    • FilenameUtils

      private FilenameUtils()
      Private constructor to prevent instantiation.
  • Method Details

    • validateFilename

      public static void validateFilename(String fileName) throws IllegalArgumentException
      Validates a filename to ensure it contains only allowed characters and does not exceed a maximum length.
      Parameters:
      fileName - the filename to validate
      Throws:
      IllegalArgumentException - if the filename is null, empty, contains invalid characters, or exceeds the maximum length