Package com.digicert.validation.utils
Class FilenameUtils
java.lang.Object
com.digicert.validation.utils.FilenameUtils
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 Summary
FieldsModifier and TypeFieldDescriptionprivate static final Pattern
Regex for one or more of the allowed char set for filename. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Private constructor to prevent instantiation. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
validateFilename
(String fileName) Validates a filename to ensure it contains only allowed characters and does not exceed a maximum length.
-
Field Details
-
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
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
-